0
У меня есть 6 TextViews, которые я использую в качестве кнопок для своего музыкального приложения. Я использую weightsum для 6 из них с layout_weight = 1
, и все еще остается место.LinearLayout WeightSum не работает
Вот мой XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="6"
tools:context="com.example.android.musicplayerapp.MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:padding="16dp"
android:textColor="@android:color/white"
android:textStyle="bold"
android:text="Now playing"
android:background="#7FB3D5"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:padding="16dp"
android:textColor="@android:color/white"
android:textStyle="bold"
android:text="Songs"
android:background="#5499C7"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:padding="16dp"
android:textColor="@android:color/white"
android:textStyle="bold"
android:text="Artists"
android:background="#2980B9"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:padding="16dp"
android:textColor="@android:color/white"
android:textStyle="bold"
android:text="Playlists"
android:background="#2471A3"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:padding="16dp"
android:textColor="@android:color/white"
android:textStyle="bold"
android:text="Store"
android:background="#1F618D"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:padding="16dp"
android:textColor="@android:color/white"
android:textStyle="bold"
android:text="Search"
android:background="#154360"/>
</LinearLayout>
Что именно здесь не так? Любая помощь приветствуется.
Можете ли вы приложите скриншот вашей проблемы? –
Кстати: 'weightSum' можно опустить - это необязательно. –