2013-03-16 40 views
0

我真的试图创建以下布局: 如何正确显示SeekBar? (layout_weight)

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

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 
    </TextView> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 
    </TextView> 

    <SeekBar 
     android:id="@+id/seekbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

    <TextView 
     android:id="@+id/textView3" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 
    </TextView> 

</LinearLayout> 

我想要一份给父布局到textView1和textView2的80%,包装搜索栏尽可能和剩余空间给textView3。

I`ve试图:

  • 使用layout_weight属性(分别 - 4,4,1,1),但在过去 视图重叠搜索栏仅
  • 使用布局重量textView1和textView2 ,将SeekBar的高度设置为“wrap_content”并将最后一个视图设置为“match_parent”

现在我没有更多的想法。你有过这样的问题吗?

回答

0

以及创建这个布局我会尝试:在权重恩调整大小

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="4" > 
</TextView> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="4" > 
</TextView> 

<SeekBar 
    android:id="@+id/seekbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

<TextView 
    android:id="@+id/textView3" 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1"> 
</TextView> 

做出改变。 让搜索栏包装内容,对其他视图给予重视。

告诉我,如果有帮助。

+0

太棒了!谢谢!它完美的作品。但是......你能告诉我为什么它有效吗? SeekBar的空间是否首先确定(因为它没有任何权重)?然后其余的按重量划分? – ppablo28 2013-03-17 15:40:10