Android ImageButton大小不小于';不适合小屏幕设备
我想知道如何设置我的应用程序内容,以便它们可以固定在至少3.5英寸的设备上 在如此小的尺寸(4英寸)的设备中看起来是这样的 如图所示,所有四个图像按钮相互重叠,在7英寸屏幕上看起来不错。Android ImageButton大小不小于';不适合小屏幕设备,android,imagebutton,Android,Imagebutton,我想知道如何设置我的应用程序内容,以便它们可以固定在至少3.5英寸的设备上 在如此小的尺寸(4英寸)的设备中看起来是这样的 如图所示,所有四个图像按钮相互重叠,在7英寸屏幕上看起来不错。 有没有办法解决这个问题 这是我的布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" an
有没有办法解决这个问题 这是我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg2"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".StartActivity" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:background="@null"
android:layout_marginLeft="24dp"
android:src="@drawable/abc" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:background="@null"
android:layout_marginRight="24dp"
android:src="@drawable/nmbrs" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@null"
android:layout_marginLeft="24dp"
android:layout_marginBottom="10dp"
android:src="@drawable/vegebtns" />
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@null"
android:layout_marginRight="24dp"
android:layout_marginBottom="10dp"
android:src="@drawable/fruitsbtn" />
</RelativeLayout>
最好参考使用每个图像按钮,如下所示
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@null"
android:layout_marginRight="24dp"
android:layout_marginBottom="10dp"
android:src="@drawable/fruitsbtn" />
如果要根据屏幕大小(而不是dpi)更改某些图像或大小,可以使用以下方法:
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
double x = Math.pow(dm.widthPixels/dm.xdpi,2);
double y = Math.pow(dm.heightPixels/dm.ydpi,2);
double screenInches = Math.sqrt(x+y);
if(screenInches > sizeYouWant){
//do what you want
}
实际上,您希望的是什么类型的设计?如果屏幕大小是确定的大小,您是否希望更改按钮的大小。像3、5或4?D,你需要一个重叠的设计?你使用的是更大的图像。它使包装内容符合他们的要求size@user3197977你的链接在哪里?