2012-10-15 180 views
1

任何人都可以幫助我給出在垂直線性佈局中開發的四個按鈕的重力,該佈局又是水平線性佈局和進度條。我需要整個按鈕和屏幕底部的進度條。請幫助我。線性佈局的重力

在此先感謝

<?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" 
> 

<LinearLayout 
android:orientation="horizontal" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
> 
    <Button 
    android:id="@+id/play" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    /> 
    <Button 
    android:id="@+id/pause" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"  /> 
    <Button 
    android:id="@+id/back" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"  /> 
    <Button 
    android:id="@+id/fwd" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"  /> 

</LinearLayout> 



<ProgressBar 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:id="@+id/progressbar_Horizontal" 
    /> 

</LinearLayout> 
+4

你能解釋更多或任何截圖? – Renjith

+2

顯示你的xml文件 –

+0

如何在這裏給XML – srinivas

回答

0
android:gravity="bottom" 

該行同時添加到您的垂直和水平的線性佈局 我想這就是你要找的人

+0

我試過這一點沒有用 – srinivas

+0

你到底有什麼問題呢? – Syn3sthete

+0

我給出了一個水平線性佈局和進度條。然後在水平線性佈局內使用4個按鈕的垂直線性佈局。整個佈局顯示在屏幕的頂部。但我希望它顯示在底部,以便我可以添加圖像。現在我應該使用哪個命令使其顯示在屏幕的底部。 – srinivas

0

與下面的代碼

更換答案
<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/btnLayout" 
android:orientation="horizontal" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_above="@+id/progressbar_Horizontal" 

> 
    <Button 
    android:id="@+id/play" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    /> 
    <Button 
    android:id="@+id/pause" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"  /> 
    <Button 
    android:id="@+id/back" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"  /> 
    <Button 
    android:id="@+id/fwd" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"  /> 

</LinearLayout> 



<ProgressBar 

    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:id="@+id/progressbar_Horizontal" 

    android:layout_alignParentBottom="true" 
    /> 

</RelativeLayout> 
1
Hi @ srinivas. 
    gravity for four buttons developed in a vertical linear layout which is again in horizontal 
    linear layout with progress bar, try out by this xml code.. its must helpful to you... 


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

    <ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

      <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="10dp" 
      android:orientation="horizontal" 
      android:weightSum="3" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="2" 
       android:text="First Name" 
       android:textColor="#000000" /> 

      <EditText 
       android:id="@+id/firstName" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@android:drawable/editbox_background_normal" 
       android:ems="10" 
       android:hint="First Name" 
       android:maxLength="20" 
       android:singleLine="true" 
       android:textColor="#000000" > 
      </EditText> 
      </LinearLayout> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="10dp" 
      android:orientation="horizontal" 
      android:weightSum="3" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="2" 
       android:text="Last Name" 
       android:textColor="#000000" /> 

      <EditText 
       android:id="@+id/lastName" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@android:drawable/editbox_background_normal" 
       android:ems="10" 
       android:hint="Last Name" 
       android:maxLength="20" 
       android:singleLine="true" 
       android:textColor="#000000" > 
      </EditText> 
      </LinearLayout> 

      <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="10dp" 
      android:orientation="horizontal" 
      android:weightSum="3" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="2" 
       android:text="UserName" 
       android:textColor="#000000" /> 

      <EditText 
       android:id="@+id/un" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@android:drawable/editbox_background_normal" 
       android:ems="10" 
       android:hint="User Name" 
       android:maxLength="20" 
       android:singleLine="true" 
       android:textColor="#000000" > 
      </EditText> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="10dp" 
      android:orientation="horizontal" 
      android:weightSum="3" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="2" 
       android:text="Password" 
       android:textColor="#000000" /> 

      <EditText 
       android:id="@+id/pw" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@android:drawable/editbox_background_normal" 
       android:ems="10" 
       android:hint="Password" 
       android:maxLength="20" 
       android:password="true" 
       android:singleLine="true" 
       android:textColor="#000000" > 
      </EditText> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="10dp" 
      android:orientation="horizontal" 
      android:weightSum="3" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="2" 
       android:text="Email" 
       android:textColor="#000000" /> 

      <EditText 
       android:id="@+id/email" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@android:drawable/editbox_background_normal" 
       android:ems="10" 
       android:hint="Email" 
       android:maxLength="20" 
       android:singleLine="true" 
       android:textColor="#000000" > 
      </EditText> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="10dp" 
      android:orientation="horizontal" 
      android:weightSum="3" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="2" 
       android:text="Phone No." 
       android:textColor="#000000" /> 

      <EditText 
       android:id="@+id/phoneNum" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@android:drawable/editbox_background_normal" 
       android:ems="10" 
       android:hint="Phone Number" 
       android:inputType="number" 
       android:maxLength="20" 
       android:singleLine="true" 
       android:textColor="#000000" > 
      </EditText> 
     </LinearLayout> 

     <Button 
      android:id="@+id/push_button" 
      android:layout_width="150dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_marginTop="10dp" 
      android:background="@drawable/rounded_button" 
      android:text="Send Data" 
      android:textColor="#ffffff" /> 
     </LinearLayout> 
     </ScrollView> 

     </LinearLayout>