2014-04-01 180 views
0

我试图显示一些单选按钮和选项卡的布局中的下拉列表,但只显示前三个单选按钮。谁能帮我这个?这是我的布局代码。当我在模拟器上运行,第二个选项卡仅显示三个单选按钮,但它应该显示三个单选按钮,文本视图和一个下拉火枪手:(我的Android应用程序布局不显示布局

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="fill_parent"> 
<TabHost android:id="@+id/tabhost" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent"> 
    <LinearLayout android:layout_width="match_parent" 
     android:id="@+id/linearLayout1" android:layout_height="fill_parent" 
     android:orientation="vertical"> 
     <TabWidget android:layout_width="match_parent" 
      android:layout_height="wrap_content" android:id="@android:id/tabs">                   </TabWidget> 
     <FrameLayout android:layout_width="match_parent" 
      android:layout_height="fill_parent" android:id="@android:id/tabcontent"> 
      <LinearLayout android:layout_width="match_parent" 
       android:layout_height="fill_parent" android:id="@+id/tab1"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:text="Choose a background colour" 
        android:id="@+id/textView" 
        android:layout_marginLeft="10dp" 
        android:layout_marginTop="10dp" 
        android:textSize="25dp" 
        android:textIsSelectable="true" /> 

      </LinearLayout> 


      <LinearLayout android:layout_width="match_parent" 
       android:layout_height="fill_parent" android:id="@+id/tab2"> 

       <RadioGroup 
        android:id="@+id/rgGroup1" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical"> 
        <RadioButton android:id="@+id/RB1" android:text="Button1" /> 
        <RadioButton android:id="@+id/RB2" android:text="Button2" /> 
        <RadioButton android:id="@+id/RB3" android:text="Button3" /> 
       </RadioGroup> 
       <TextView 
        android:id="@+id/txtRadio" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="RadioGroup: Nothing picked" 
        /> 
       <Spinner 
        android:id="@+id/spnMusketeers" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_marginTop="2dp" 
        /> 

       </LinearLayout> 
      <LinearLayout android:layout_width="match_parent" 
       android:layout_height="fill_parent" android:id="@+id/tab3"> 
       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Add a tab" 
        android:id="@+id/bAddTab" /> 

       </LinearLayout> 
     </FrameLayout> 
    </LinearLayout> 
    </TabHost> 

</LinearLayout> 

回答

0

默认方向为列表的LinearLayout是水平的,所以你应该添加定位属性:

<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/tab2"> 
+0

非常感谢!真的有帮助! – user3388470

0

你只是忘了指定LinearLayout S的方向,否则它是作为horizontal默认处理它应该是这样的:

<LinearLayout android:layout_width="match_parent" 
       android:layout_height="fill_parent" 
       android:id="@+id/tab1" 
       android:orientation="vertical"> 

请注意,我已经添加android:orientation="vertical"

+0

非常感谢!我给了另一个人绿色的勾号,因为他没有你那么多的奖牌,我认为这是很好的提升,他更详细。 :)非常感谢,谢谢:) – user3388470