<?xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorAccent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@color/colorPrimaryDark"
android:text="測試一下測試一下測試一下測試一下測試一下測試一下測試一下測試一下測試一下測試一下測試一下"
android:textSize="70sp" /></ScrollView>
1 回答

Helenr
TA貢獻1780條經驗 獲得超4個贊
scrollview實際寬高在代碼中~=(約等于)屏幕寬高,驗證方法,可以在Activity中輸出scrollview的高度 實際是約等于屏幕高度,而不是內容高度
然后它還有content寬高,這個寬高是根據內容的大小決定。android:layout_gravity="center"
是讓TextView的中心對齊scrollview的中心,并不能對齊scrollview的content中心
如果想實現對齊content中心 建議在TextView外層包裹一個LinearLayout或者其他ViewGroup
添加回答
舉報
0/150
提交
取消