簡體   English   中英

LinearLayout-3個彼此相鄰的對象

[英]LinearLayout - 3 objects next to each other

這將是一個非常簡單的問題,但是我在其他主題上嘗試了很多答案,但無濟於事:/

我所擁有的和我想要的: 在此處輸入圖片說明

我的代碼:

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="@dimen/spacing_medium">

        <LinearLayout
            android:id="@+id/lyt_fullname_upload"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/selectableItemBackground"
            android:clickable="true"
            android:gravity="center_vertical"
            android:minHeight="@dimen/spacing_xxlarge"
            android:onClick="clickLayout"
            android:orientation="horizontal">


            <ImageView
                android:layout_width="@dimen/spacing_mlarge"
                android:layout_height="@dimen/spacing_mlarge"
                android:layout_margin="@dimen/spacing_middle"
                android:src="@drawable/ic_name_mountain_212121"

                android:tint="@color/colorPrimaryBlack" />

            <TextView
                android:id="@+id/textView_counter"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_alignParentLeft="true"
                android:text="5" />

            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">


                <EditText
                    android:id="@+id/fullname_upload"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:maxLength="250"
                    android:layout_margin="@dimen/spacing_medium"
                    android:hint="@string/placeholder_chillspot_name"
                    android:textSize="18sp"
                    android:text="sagdkojsgdfjiklnsagdikljsgdafnmkljsagdfmlskagdmgsdaůlksmdgklůsgdamlůksagdsdfztpkmtzrskoůltzersklůodmsljkdmgslkjdgmslkgsedmlgfůdekmgerlaskůmsgadflůsgm,aasgklů,"/>
            </android.support.design.widget.TextInputLayout>

        </LinearLayout>

我嘗試對齊這些對象,布局權重等,但是我在做一些錯誤。

嘗試這個:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="@dimen/spacing_medium">

        <LinearLayout
            android:id="@+id/lyt_fullname_upload"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/selectableItemBackground"
            android:clickable="true"
            android:gravity="center_vertical"
            android:minHeight="@dimen/spacing_xxlarge"
            android:onClick="clickLayout"
            android:orientation="horizontal">


            <ImageView
                android:layout_width="@dimen/spacing_mlarge"
                android:layout_height="@dimen/spacing_mlarge"
                android:layout_margin="@dimen/spacing_middle"
                android:src="@drawable/ic_name_mountain_212121"

                android:tint="@color/colorPrimaryBlack" />    


            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">


                <EditText
                    android:id="@+id/fullname_upload"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:maxLength="250"
                    android:layout_margin="@dimen/spacing_medium"
                    android:hint="@string/placeholder_chillspot_name"
                    android:textSize="18sp"
                    android:text="sagdkojsgdfjiklnsagdikljsgdafnmkljsagdfmlskagdmgsdaůlksmdgklůsgdamlůksagdsdfztpkmtzrskoůltzersklůodmsljkdmgslkjdgmslkgsedmlgfůdekmgerlaskůmsgadflůsgm,aasgklů,"/>
            </android.support.design.widget.TextInputLayout>

            <TextView
                android:id="@+id/textView_counter"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_alignParentLeft="true"
                android:gravity="top"
                android:text="5" />

        </LinearLayout>

我只是更改了一些填充和邊距以查看結果,但要點是更改TextView的位置並使用ImageView TextView和TextInputLayout的權重

  <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="@dimen/spacing_normal">

        <LinearLayout
            android:id="@+id/lyt_fullname_upload"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/selectableItemBackground"
            android:clickable="true"
            android:gravity="center_vertical"
            android:onClick="clickLayout"
            android:orientation="horizontal">


            <ImageView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_margin="@dimen/spacing_normal"
                app2:srcCompat="@drawable/ic_swap"
                android:backgroundTint="@color/bb_darkBackgroundColor"

                android:tint="@color/amber_50" />



            <android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_password"
                android:layout_width="0dp"
                android:layout_weight="10"
                android:layout_height="wrap_content">


                <EditText
                    android:id="@+id/fullname_upload"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="@dimen/spacing_normal"
                    android:maxLength="250"
                    android:text="sagdkojsgdfjiklnsagdikljsgdafnmkljsagdfmlskagdmgsdaůlksmdgklůsgdamlůksagdsdfztpkmtzrskoůltzersklůodmsljkdmgslkjdgmslkgsedmlgfůdekmgerlaskůmsgadflůsgm,aasgklů,"
                    android:textSize="18sp" />
            </android.support.design.widget.TextInputLayout>
            <TextView
                android:id="@+id/textView_counter"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_weight="1"
                android:layout_alignParentTop="true"
                android:text="5" />

        </LinearLayout>
    </LinearLayout>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM