标签:android layout spinner relativelayout
我有以下RelativeLayout:
<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"
android:orientation="horizontal" >
<RadioGroup
<!--stuff-->
</RadioGroup>
<Spinner
android:id="@+id/colour_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/radioGroup1" />
<TextView
android:id="@+id/colourLabel"
android:text="@string/label_colour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/radioGroup1"
android:layout_toLeftOf="@+id/colour_spinner"/>
<Spinner
android:id="@+id/country_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/colour_spinner" />
<TextView
android:id="@+id/countryLabel"
android:text="@string/label_country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/colour_spinner"
android:layout_toLeftOf="@+id/country_spinner"/>
<Spinner
android:id="@+id/stadium_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/country_spinner" />
<TextView
android:id="@+id/stadiumLabel"
android:text="@string/label_stadium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/country_spinner"
android:layout_toLeftOf="@+id/stadium_spinner"/>
希望我在这里尝试做的很明显.三个旋转器,每个都在前一个下方,每个左侧都有一个标签,理想情况下整齐排列.
我现在得到的结果是,只有微调器显示在屏幕上,我根本没有文本标签.我在这做错了什么?我怀疑这与我的布局宽度/高度设置有关?
解决方法:
将每个微调器和标签包含在水平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">
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- stuff -->
</RadioGroup>
<LinearLayout
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/radioGroup"
android:orientation="horizontal" >
<TextView
android:id="@+id/colourLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_colour" />
<Spinner
android:id="@+id/colour_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/spinner1"
android:orientation="horizontal" >
<TextView
android:id="@+id/countryLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/label_country" />
<Spinner
android:id="@+id/country_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="@+id/spinner3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/spinner2"
android:orientation="horizontal" >
<TextView
android:id="@+id/stadiumLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_stadium" />
<Spinner
android:id="@+id/stadium_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</RelativeLayout>
标签:android,layout,spinner,relativelayout 来源: https://codeday.me/bug/20190825/1723393.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。