0

在我的佈局,我有四塊這樣的:如何在水平LinearLayout中垂直對齊EditText和ProgressBar?

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <EditText 
     android:id="@+id/label1" 
     android:layout_width="100dip" 
     android:layout_height="wrap_content" 
     android:clickable="false" 
     android:focusable="false" 
     android:focusableInTouchMode="false" 
     android:text="@string/freq_1_50" /> 
    <ProgressBar android:id="@+id/progress_horizontal1" 
     style="?android:attr/progressBarStyleHorizontal" 
     android:layout_width="100dip" 
     android:layout_height="wrap_content" 
     android:max="100" 
     android:progress="50" /> 
    <EditText 
     android:id="@+id/textScore1" 
     android:layout_width="100dip" 
     android:layout_height="wrap_content" 
     android:focusable="false" 
     android:focusableInTouchMode="false" 
     android:inputType="none" 
     android:text="50%" /> 

</LinearLayout> 

在這張照片中的Android模擬器得到的:

enter image description here

顯而易見的問題是:我怎麼去在垂直取向EditText和進度條?

在此先感謝!

下面是添加中心屬性的所期望的結果:

enter image description here

問題解決了!

+0

我很好奇,你是怎麼解決它的? – JJ86 2013-03-22 16:04:10

回答

2

添加android:gravity = "center"到您的線性佈局嘗試

<LinearLayout 
android:orientation="horizontal" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 

安卓重力= 「中心」>

<EditText 
    android:id="@+id/label1" 
    android:layout_width="100dip" 
    android:layout_height="wrap_content" 
    android:clickable="false" 
    android:focusable="false" 
    android:focusableInTouchMode="false" 
    android:text="@string/freq_1_50" /> 
<ProgressBar android:id="@+id/progress_horizontal1" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:layout_width="100dip" 
    android:layout_height="wrap_content" 
    android:max="100" 
    android:progress="50" /> 
<EditText 
    android:id="@+id/textScore1" 
    android:layout_width="100dip" 
    android:layout_height="wrap_content" 
    android:focusable="false" 
    android:focusableInTouchMode="false" 
    android:inputType="none" 
    android:text="50%" /> 

+0

是的,我從這裏發現它自己:http://thinkandroid.wordpress.com/2010/01/14/how-to-position-views-properly-in-layouts/謝謝! – jhulst 2013-03-22 13:41:47

+0

所需的輸出屏幕快照發布在問題中。問題解決了。 – jhulst 2013-03-22 13:48:33

0

正上方