2015-09-28 74 views
-2

當涉及到android中的佈局時,我感到困惑。android studio中的佈局

我想獲得一個類似於下圖的佈局,其中文本字段一直到右側,文本以某種方式在中間左右對齊。有人可以幫助我獲得作爲附加圖像的佈局嗎?

layout image

enter image description here

也能有人弄清楚什麼是附加的圖像中的文本和尺寸的名稱。我喜歡它,並希望在我的應用程序中使用它。

我明白,如果有人可以發佈一些XML代碼來獲取圖片中的佈局(鏈接附加)。

一個簡單的例子,兩個或三個文本和相應的文本框對齊爲圖片顯示就足夠了。

感謝

回答

0

我在這裏提供一個包含佈局的前三行基本佈局..

請試試這個,並添加所有的下一個實體,讓我知道,如果你堅持的地方..!

<LinearLayout 
    android:id="@+id/linear_description" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <TextView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="end" 
     android:text="Description" 
     android:textAlignment="gravity" 
     android:textStyle="bold" /> 

    <EditText 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="2" /> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/linear_amount" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/linear_description" 
    android:orientation="horizontal" 
    android:weightSum="6"> 

    <TextView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="2" 
     android:gravity="end" 
     android:text="Amount" 
     android:textAlignment="gravity" 
     android:textStyle="bold" /> 

    <EditText 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="3" /> 

    <Button 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="@android:drawable/btn_star_big_off" /> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/linear_tax" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/linear_amount" 
    android:orientation="horizontal" 
    android:weightSum="6"> 

    <TextView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="2" 
     android:gravity="end" 
     android:text="Tax" 
     android:textAlignment="gravity" 
     android:textStyle="bold" /> 

    <EditText 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="3" /> 

    <Button 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="@android:drawable/btn_star_big_off" /> 
</LinearLayout> 

謝謝!!

+0

AndiGeeky或任何人誰​​可以幫忙,怎樣才能使當金額部分的按鈕按鍵盤上的出現?基本上我想要做的是,當按鈕與星星按下時,它會調出虛擬鍵盤,以便我可以鍵入一個數字,然後數字顯示在數量文本字段。任何想法如何做到這一點? – yoohoo

+0

@yoohoo:如果這個答案適合你,那麼請接受它,以便其他人可以導致最好的答案..!謝謝。 – AndiGeeky

+0

@yoohoo:對於第二個查詢請添加新的問題,以便更多的人可以幫助你..! – AndiGeeky

0

您可以使用此

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

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

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Description" 
      android:textColor="#000000" > 
     </TextView> 

     <EditText 
      android:id="@+id/editText1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" /> 
    </LinearLayout> 

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

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Amount" 
      android:textColor="#000000" > 
     </TextView> 

     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" /> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 

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

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Amount" 
      android:textColor="#000000" > 
     </TextView> 

     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" /> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Help" /> 
    </LinearLayout> 

</LinearLayout>