2012-03-21 3 views
0

Я хотел бы обратиться к проблеме размещения xml. У меня есть основное действие, которое является TabActivity, и оно заполнено (вкладки) другим действием, которое является ListActivity. На скрине вместе с основной TabActivity я хочу показать серая полоска с кнопками (-ами) в нижней части страницы. Проблема в том, что последний элемент списка скрыт полосой. Так что мне нужно, чтобы этот список должен иметь границу в той же точке, где начинается граница полосы кнопок. Это демонстрируется картина здесь:Наложение наложения XML на Android

http://postimage.org/image/h8yx7jxlj/

Я уже пытался изменить layout_height параметр нескольких макетов для wrap_content, но hasn't помог ...

PS Есть ли способ, как изменить размер шрифта заголовка вкладки IN XML LAYOUT FILE?

Это мой XML макет основной деятельности:

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

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
<LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="5dp"> 

    <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 


    <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:padding="5dp" /> 


</LinearLayout> 

<LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:gravity="center" 
     android:background="#666666"> 

    <Button android:id="@+id/settins_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="1sp" 
      android:text="volba zdrojů" 
      android:enabled="false" /> 

</LinearLayout> 

Это расположение XML-код активности, который вставляется в TabControl в качестве содержимого вкладки. (затем вставлен в FrameLayout блока управления табло):

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

<ListView 
     android:id="@+id/android:list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"/> 


<TextView 
     android:id="@+id/android:empty" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="center_vertical|center_horizontal" 
     android:text="@string/main_no_items"/> 

</LinearLayout> 

Большое спасибо!

+0

Я думаю, что проблема связана с верхней LinearLayout имеет свою высоту установленные в fill_parent, в то время как нижняя LinearLayout имеет гравитацию на него, в результате чего он не занимать никакого места по сравнению с TabHost. Попробуйте изменить верхний LinearLayout на wrap_content для высоты. –

ответ

1

Используйте RelativeLayout вместо LinearLayout. Пожалуйста, см. Прилагаемый код, который делает именно то, что вы хотите.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#FFFFFF" > 

    <TextView 
     android:id="@+id/text" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@+id/button" 
     android:layout_alignParentTop="true" 
     android:gravity="center_horizontal" 
     android:text="some text goes here" 
     android:textColor="#1E1E1E" 
     android:textSize="25sp" /> 

    <LinearLayout 
     android:id="@+id/button" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/btn_send" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="15dp" 
      android:layout_marginRight="15dp" 
      android:layout_weight="50" 
      android:onClick="handleSendReport" 
      android:text="@string/button_send" /> 
    </LinearLayout> 

</RelativeLayout> 
Смежные вопросы