Как сделать этот дизайн Android? - PullRequest
0 голосов
/ 10 апреля 2019

У меня есть этот дизайн:

enter image description here

, и я не могу представить, как создать что-то подобное.Вначале я использовал bottomNavgationview, но это не помогло мне, потому что я не могу сделать это перекрытие выбранного элемента и выровнять текст на элементе.Теперь я создал свой собственный вид, основанный на linearLayout:

<LinearLayout
        android:id="@+id/navigation_view"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:layout_marginTop="5dp"
        android:background="@color/white">

        <TextView
            android:id="@+id/received"
            android:layout_width="0dp"
            android:layout_height="56dp"
            android:layout_weight="6"
            android:gravity="center"
            android:layout_gravity="end"
            android:textColor="#565D63"
            android:fontFamily="@font/opensans_semibold"
            android:text="@string/received"
            android:textAlignment="center" />

        <TextView
            android:id="@+id/sent"
            android:layout_width="0dp"
            android:layout_height="56dp"
            android:layout_weight="6"
            android:gravity="center"
            android:textColor="#565D63"
            android:fontFamily="@font/opensans_semibold"
            android:text="@string/sent"
            android:textAlignment="center" />

        <TextView
            android:id="@+id/draft"
            android:layout_width="0dp"
            android:layout_height="56dp"
            android:layout_weight="6"
            android:textColor="#565D63"
            android:fontFamily="@font/opensans_semibold"
            android:gravity="center"
            android:text="@string/drafts"

            android:textAlignment="center" />

    </LinearLayout>

, и я попытался программно установить translationZ, но мне не удалось достичь своего дизайна.У меня были некоторые мысли о framelayout из этого и этого вопросов, но это не помогло мне.Может кто знает как я могу решить мою проблему?

Ответы [ 3 ]

1 голос
/ 10 апреля 2019

enter image description here

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal">

        <TextView
            android:layout_width="0dp"
            android:layout_weight="2"
            android:layout_gravity="center"
            android:textColor="#000"
            android:gravity="center"
            android:text="dsgd"
            android:background="#F9E79F"
            android:layout_height="match_parent" />

        <TextView
            android:layout_width="0dp"
            android:layout_weight="2"
            android:textColor="#000"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="dsgd"
            android:layout_height="match_parent" />

        <TextView
            android:layout_width="0dp"
            android:layout_weight="2"
            android:textColor="#000"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="dsgd"
            android:layout_height="match_parent" />

</LinearLayout>
1 голос
/ 11 апреля 2019

Попробуйте это.

 <LinearLayout
        android:id="@+id/navigation_view"
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:layout_marginTop="5dp"
        android:orientation="horizontal"
        android:background="@color/white">

        <TextView
            android:id="@+id/received"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="6"
            android:gravity="center"
            android:layout_gravity="end"
            android:textColor="#565D63"
            android:fontFamily="@font/opensans_semibold"
            android:text="@string/received"
            android:textAlignment="center" />

        <TextView
            android:id="@+id/sent"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="6"
            android:gravity="center"
            android:textColor="#565D63"
            android:fontFamily="@font/opensans_semibold"
            android:text="@string/sent"
            android:textAlignment="center" />

        <TextView
            android:id="@+id/draft"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="6"
            android:textColor="#565D63"
            android:fontFamily="@font/opensans_semibold"
            android:gravity="center"
            android:text="@string/drafts"
            android:textAlignment="center" />

    </LinearLayout>

Надеюсь, это поможет !!!

Я думаю, вы забыли добавить ориентацию в родительский макет.

1 голос
/ 10 апреля 2019

Я немного изменил ваш код, это должно помочь.

 <LinearLayout
            android:id="@+id/navigation_view"
            android:layout_width="match_parent"
            android:layout_height="180dp"
            android:layout_marginTop="5dp"
            android:background="@color/white">

            <TextView
                android:id="@+id/received"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="6"
                android:gravity="center"
                android:layout_gravity="end"
                android:textColor="#565D63"
                android:fontFamily="@font/opensans_semibold"
                android:text="@string/received"
                android:textAlignment="center" />

            <TextView
                android:id="@+id/sent"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="6"
                android:gravity="center"
                android:textColor="#565D63"
                android:fontFamily="@font/opensans_semibold"
                android:text="@string/sent"
                android:textAlignment="center" />

            <TextView
                android:id="@+id/draft"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="6"
                android:textColor="#565D63"
                android:fontFamily="@font/opensans_semibold"
                android:gravity="center"
                android:text="@string/drafts"
                android:textAlignment="center" />

        </LinearLayout>

Этот код создаст все текстовые просмотры, соответствующие высоте вашего линейного макета, теперь после этого вы можете установить цвет фона текстового просмотра по умолчанию в соответствии с вашим дизайном, и если при щелчке используется, то вы можете сделать это тоже.

...