[英]can anyone tell me how to store geocoder address in android database using android studio?
[英]Can Anyone Tell Me Why This Text Is Not Centering In Android Studio?
我正在嘗試對齊文本,就像您希望看到的那樣,如果您在寫字板中,並將對齊方式設置為居中,則每行的中間將位於屏幕的中心,而左右各邊距將等距。 但是,使用重力似乎無效,因為文本仍從左側開始。 有人能解釋為什么嗎? 這是xml。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:orientation="vertical"
android:background="#111111"
tools:context="eqlogic.annswingsandthings.AboutUs">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/chalkBoard"
android:src="@drawable/ann_chalkboard_img"
android:layout_weight="0.5"/>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:id="@+id/scrollView"
android:layout_gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:textColor="#999999"
android:text="@string/AboutUsText"
android:textSize="24sp"
android:id="@+id/textView"
android:layout_gravity="center_horizontal"
android:singleLine="false" />
</ScrollView>
</LinearLayout>
您沒有設置重力,請使用:
android:gravity="center"
完整標簽:
<TextView
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:textColor="#999999"
android:text="@string/AboutUsText"
android:textSize="24sp"
android:id="@+id/textView"
android:layout_gravity="center_horizontal"
android:singleLine="false" />
還將ScrollView
android:gravity
參數設置為center
。
為了測試不同布局參數的效果,我建議為每個元素使用不同的背景色,這樣您就可以看到布局如何隨着重力,layout_gravity或其他參數而變化。
使您的layout_width為fill_parent並使用重力代替layout_gravity :
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:textColor="#999999"
android:text="@string/AboutUsText"
android:textSize="24sp"
android:id="@+id/textView"
android:gravity="center"
android:singleLine="false" />
設置滾動視圖參數Android:layout_width =“ match_parent”和Android:gravity =“ center”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.