2015-09-28 66 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>