Вот сравнение того, что мой редактор и устройство показывает:Android макет даже интервал
Проблема заключается в том:
- строка, содержащая TextView должны принять 50% экрана
- строка, содержащая значок, должна содержать оставшиеся 50% экрана
Он корректно работает в редакторе, но, как вы видите, макет ведет себя по-разному на самом устройстве.
Где моя проблема и как ее решить?
Библиотека используется для иконы: https://github.com/code-mc/material-icon-lib
Он простирается непосредственно от ImageView.
Layout XML:
<TableLayout
android:id="@+id/menuLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*" >
<TableRow
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<LinearLayout
android:layout_weight="1"
android:orientation="horizontal"
android:layout_height="match_parent"
android:layout_width="match_parent">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/teenSelection"
android:textColor="@color/WHITE"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="30sp"
android:text="TEEN" />
<android.support.v7.widget.AppCompatTextView
android:id="@+id/adultSelection"
android:textColor="@color/WHITE"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="30sp"
android:text="ADULT"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/seniorSelection"
android:textColor="@color/WHITE"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="30sp"
android:text="SENIOR"/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<net.steamcrafted.materialiconlib.MaterialIconView
android:layout_weight="1"
android:id="@+id/confirmButton"
app:materialIcon="check"
app:materialIconColor="#fff"
android:scaleType="center"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
</TableRow>
</TableLayout>
Вы пытались установить андроид: layout_weight = "0.5" в первом TableRow? –
Я думаю, проблема связана с вашим столом. вы установили вес в 1, но layout_height - wrap_content. используйте match_parent вместо этого ... – Opiatefuchs
Как отметил Мигель Бенитес, вы пробовали установить как android_layout_weigth на 0,5? – Ricardo