LinearLayout - 彼此相邻的3个对象

时间:2017-06-23 20:17:25

标签: android android-layout

这将是一个非常简单的问题,但我在其他主题中尝试了很多答案而没有任何帮助:/

我拥有的和我想要的: enter image description here

我的代码:

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

我尝试对齐这些对象,布局权重等等,但我在做某个愚蠢的错误。

Tahnks寻求帮助的人:)

2 个答案:

答案 0 :(得分:0)

试试这个:

library(tidyverse)
data("iris")

my_table <- function(df, group_var) {
  group_var <- enquo(group_var)      # Create quosure
  df %>% 
    group_by(!!group_var) %>%        # Use !! to unquote the quosure
    summarise(n = n())
}

my_table(iris, Species)

> my_table(iris, Species)
# A tibble: 3 x 2
     Species     n
      <fctr> <int>
1     setosa    50
2 versicolor    50
3  virginica    50

答案 1 :(得分:0)

我只是更改了一些填充和边距以查看结果,但主要的一点是更改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>