是否有可能在linearLayout方向垂直方向上并排查看

时间:2015-06-15 16:39:05

标签: android

我想让2个观点像这样并排:

标题:EditText

但问题是android:orientation="vertical"中的LinearLayout,我可以做到吗?

这是我的代码

    <?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"
    android:weightSum="1">

    <EditTextView
        android:layout_width="wrap_content"
        android:layout_height="58dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:id="@+id/edittext" />


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="34dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Medium Text"
        android:id="@+id/textView"
        android:layout_alignParentBottom="true" />
   </LinearLayout>

2 个答案:

答案 0 :(得分:0)

用于两种观点:

android:layout_weight="1"

插入垂直布局中插入的水平布局

答案 1 :(得分: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="horizontal"
android:weightSum="3">

<EditTextView
    android:layout_width="0dp"
    android:layout_height="58dp"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:id="@+id/edittext"
    android:layout_weight="2"/>


<TextView
    android:layout_width="0dp"
    android:layout_height="34dp"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Medium Text"
    android:id="@+id/textView"
    android:layout_weight="1" />
</LinearLayout>