问题描述
我写了一个布局。在布局上有5个按钮。
I wrote a layout. On the layout there are 5 buttons.
http://imageshack.us/photo/my-images/607/layout.gif/
下面是我的Tablelayout:
Here is my Tablelayout:
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="0,1" android:stretchColumns="*">
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14dp"
android:text="Hello"
android:layout_span="5"
android:paddingTop="27dp"
android:paddingBottom="25dp"
android:textColor="#ffffff"
android:gravity="center" />
</TableRow>
<TableRow>
<FrameLayout
android:layout_weight="0.2">
</FrameLayout>
<FrameLayout
android:layout_weight="0.2">
<ImageButton
android:id="@+id/ImageButton1"
android:background="@drawable/ImageButton1"
android:layout_width="97dp"
android:layout_height="90dp"
android:layout_gravity="center"
android:scaleType="center"
/>
</FrameLayout>
<FrameLayout
android:layout_weight="0.2">
<ImageButton
android:id="@+id/ImageButton2"
android:layout_width="97dp"
android:layout_height="90dp"
android:background="@drawable/ImageButton2"
android:layout_gravity="center"
android:scaleType="center" />
</FrameLayout>
<FrameLayout
android:layout_weight="0.2">
<ImageButton
android:id="@+id/ImageButton3"
android:layout_width="97dp"
android:layout_height="90dp"
android:background="@drawable/ImageButton3"
android:layout_gravity="center"
android:scaleType="center" />
</FrameLayout>
<FrameLayout
android:layout_weight="0.2">
</FrameLayout>
</TableRow>
<TableRow>
<FrameLayout
android:layout_weight="0.2">
</FrameLayout>
<TextView
android:textSize="12dp"
android:text="Text1"
android:padding="3dp"
android:textColor="#fff"
android:gravity="center" />
<TextView
android:textSize="12dp"
android:text="Text2"
android:padding="3dp"
android:textColor="#fff"
android:gravity="center" />
<TextView
android:textSize="12dp"
android:text="Text3"
android:padding="3dp"
android:textColor="#fff"
android:gravity="center" />
<FrameLayout
android:layout_weight="0.2">
</FrameLayout>
</TableRow>
<View
android:layout_height="30dp" />
<TableRow>
<FrameLayout
android:layout_weight="0.2">
</FrameLayout>
<FrameLayout
android:layout_weight="0.2">
<ImageButton
android:id="@+id/ImageButton4"
android:layout_width="97dp"
android:layout_height="90dp"
android:background="@drawable/ImageButton4"
android:scaleType="center"
android:layout_gravity="center" />
</FrameLayout>
<FrameLayout
android:layout_weight="0.2">
<ImageButton
android:id="@+id/ImageButton5"
android:layout_width="97dp"
android:layout_height="90dp"
android:background="@drawable/ImageButton5
android:scaleType="center"
android:layout_gravity="center" />
</FrameLayout>
<FrameLayout
android:layout_weight="0.2">
</FrameLayout>
<FrameLayout
android:layout_weight="0.2">
</FrameLayout>
</TableRow>
</TableLayout>
一切工作好我大的智能手机。但是,当我看到它与我小的智能手机没有足够的空间,再在屏幕下方。我怎样才能改变它的话,该表格布局扩展的一切。
Everything works good on my big smartphone. But when i look it with my small smartphone there is not enough space anymore on the bottom Screen. How can i change it so, that the Table layout scales everything.
我为这个位置的图像按钮:
I gave this here by the Image Buttons:
android:layout_width="97dp"
android:layout_height="90dp"
这就是原因,为什么会出现在小智能手机的底部不足够的空间。该表的布局应缩放图像按钮。图像按钮有不是正方形的形式。它像长方形。
That's the reason, why there is not more enough space in the bottom of the small smartphone. The Table layout should scale the Image Buttons. The Image Button has not a square form. Its like rectangle.
表格的布局应是水平的100%和垂直100%。
The Table layout should be horizontal 100% and vertical 100%.
推荐答案
我认为这个问题是由于缩放,它不是根据屏幕尺寸按比例缩小。 你需要做出新的绘制适当的密度为所有三个类别华电国际,MDPI和LDPI。
I think the problem is due to scaling , it is not scaling down according to screen size . You need to make new drawable with proper densities for all three categories hdpi , mdpi and ldpi .
有关计算,你需要什么样的密度,你可以使用此工具 http://labs.skinkers.com/content/android_dp_px_calculator/
For calculating what density you require you can use this tool http://labs.skinkers.com/content/android_dp_px_calculator/
缩放取决于两件事情的屏幕大小以及屏幕密度。
Scaling depends on two things screen size as well as screen density .
有关更多信息,你可以看看到开发者网站你会发现如何机器人大致缩放图像
For More info you can look into the developer site you will find how android roughly scales the images
这篇关于机器人 - 布局 - 调整ImageButtons?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!