我有一个简单的屏幕有4个按钮和其图像: 按钮文本丢失时在横向模式
,当我将其更改为横向模式影像得到裁剪和文本丢失:
我目前使用的线性布局如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:background="@drawable/rings" >
<LinearLayout
android:id="@+id/row1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="top|fill_vertical"
android:orientation="horizontal" >
<Button
android:id="@+id/classesButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:drawable/menuitem_background"
android:contentDescription="@string/title_activity_class_list"
android:drawableBottom="@drawable/ic_classes"
android:onClick="viewClasses"
android:scaleType="fitCenter"
android:text="@string/classes"
android:minLines="1"
android:textColor="@android:color/primary_text_light" />
<Button
android:id="@+id/studentsButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:drawable/menuitem_background"
android:drawableBottom="@drawable/ic_students"
android:onClick="viewStudents"
android:scaleType="fitCenter"
android:text="@string/students"
android:minLines="1"
android:textColor="@android:color/primary_text_light" />
</LinearLayout>
<LinearLayout
android:id="@+id/row2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom|fill_vertical"
android:orientation="horizontal" >
<Button
android:id="@+id/levelsButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:drawable/menuitem_background"
android:contentDescription="@string/levels"
android:drawableBottom="@drawable/ic_levels"
android:minLines="1"
android:onClick="viewLevels"
android:scaleType="fitCenter"
android:text="@string/levels"
android:textColor="@android:color/primary_text_light" />
<Button
android:id="@+id/skillsButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:drawable/menuitem_background"
android:contentDescription="@string/skills"
android:drawableBottom="@drawable/ic_skills"
android:onClick="viewSkills"
android:scaleType="fitCenter"
android:text="@string/skills"
android:minLines="1"
android:textColor="@android:color/primary_text_light" />
</LinearLayout>
</LinearLayout>
更新我改变了规模型向fitCenter和预期那解决问题却没有。我真的很困惑,为什么缩放不会调整图像的大小以适应内部布局,看起来像其他人发现它可以缩放图像以适应屏幕。
我已经尝试使用相对布局,但无法找到一个简单的方法有4个按钮填充屏幕同样。
在此先感谢,我已经花了太多时间在这!
我知道这是不是一个答案,但对于那种你正在使用的布局,你可能只是想单纯考虑禁用横向模式。它看起来并不需要太多。它可以为您节省大量头痛! – 2014-12-02 03:04:29
这是一个合理的想法亚历克斯,不幸的是我发现,即使在纵向模式下,其他屏幕尺寸也有问题,所以我有一个更大的问题来解决,如果我可以获得肖像和景观的工作,我认为将解决。 – bitrock 2014-12-07 22:03:30