2013-05-29 4 views
0

Я разрабатываю приложение для Android для SPen. У меня возникли проблемы с получением нижнего меню в пределах LinearLayout для отображения ниже SCanvasView в пределах ReletiveLayout. Это должен быть атрибут, который я установил в canvas_container, так как я могу показать нижнее меню, когда я устанавливаю высоту canvas_container на определенный размер.Android: меню внизу макета

Атрибут, который я даю нижнему меню, - android: layout_alignParentBottom = "true".

Чтобы упростить компоновку: Я просто хочу, панель меню сверху и снизу (как содержащий ImageViews) и пространство между ними заполняется с SCanvasView и ImageView (как один и тот же размер).

Вот несколько упрощенный код:

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

    <LinearLayout 
     android:id="@+id/menu1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content">        
     <ImageView 
      android:gravity="left" 
      android:id="@+id/iv_top1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:src="@drawable/topimage1" 
      android:layout_weight=".25"/> 
     <ImageView 
      android:gravity="left" 
      android:id="@+id/iv_top2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:src="@drawable/topimage2" 
      android:layout_weight=".25"/>   
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/menu4" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:weightSum="1.0" 
     android:layout_alignParentBottom="true"> 
     <ImageView 
      android:gravity="left" 
      android:id="@+id/iv_bottom1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:src="@drawable/bottomimage1" 
      android:layout_weight=".25"/> 
     <ImageView 
      android:gravity="left" 
      android:id="@+id/iv_bottom1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:src="@drawable/bottomimage1" 
      android:layout_weight=".25"/> 
    </LinearLayout> 

    <RelativeLayout 
     android:id="@+id/canvas_container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <com.samsung.spensdk.SCanvasView 
      android:id="@+id/canvas_view" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" /> 

     <ImageView 
      android:id="@+id/imgView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:visibility="gone"/> 
    </RelativeLayout> 

</RelativeLayout> 

ответ

1

Я думаю, что я не понял, но LinearLayout с вертикальной orientation, вероятно, будет лучше в этой ситуации. Таким образом, вы можете использовать weightSum. Установите weightSum на 4, затем вес каждого LinearLayout для меню 1 и RelativeLayout весом до 2 или отрегулируйте его в соответствии с тем, что вы хотите.

Также обратите внимание, что RelativeLayout не имеет orientation. А при использовании weights и weightSum вы хотите, чтобы ваши width для каждого View быть 0 dp для horizontal orientation и height набор для 0dp для vertical orientation

Смежные вопросы