![](/img/trans.png)
[英]How to align a View below a TextView in a RelativeLayout in Android
[英]How to align spinner view inside RelativeLayout in Android?
我試圖將微調器設置在相對布局的中心。 我的嘗試如下:
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/typesSpinner"/>
</LinearLayout>
在其他情況下,這對我來說效果很好,但不適用於微調器。 為什么?
假設您實際上需要RelativeLayout
而不是LinearLayout
作為包裝器。 以下應該工作:
<RelativeLayout 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">
<Spinner
android:id="@+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.