我有一个带有图像和文本视图的网格布局..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@drawable/bg">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="2"
android:columnWidth="90dp"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:gravity="center"
android:stretchMode="columnWidth" >
</GridView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:id="@+id/testheader"
android:gravity="center"
android:layout_alignParentBottom="true" >
</RelativeLayout>
</RelativeLayout>
布局:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_weight="20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp">
<ImageView
android:id="@+id/img"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:baselineAlignBottom="false"
android:visibility="visible"
android:layout_gravity="center"
android:textAlignment="center">
</ImageView>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:id="@+id/txt"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="101dp"
android:textStyle="bold"
android:textColor="#3a08ff"
android:textSize="10dip" />
</RelativeLayout>
当我在小屏幕尺寸的设备中查看时似乎没有问题。但是当我在较大的设备中查看相同内容时,图像视图看起来更小。我怎么能克服它?
答案 0 :(得分:1)
使用imageview的ScaleType属性将其保留为
Scaletype="fitXY"
希望这对你有用
答案 1 :(得分:1)
试试这个:
int h,w;
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int density = metrics.densityDpi;
int width = 0, height = 0;
metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
height = metrics.heightPixels;
width = metrics.widthPixels;
if(width >480 && width <780)
{
setContentView(R.layout.home_module);
gridView = (GridView) findViewById(R.id.gridView1);
gridView.setNumColumns(3);
if(density <200)
{
h=200;
w=200;
CustomAdapter mAdapter;
mAdapter = new CustomAdapter(this,prgmNameList, prgmImages,h,w);
gridView.setAdapter(mAdapter);
}
else
{
h=200;
w=200;
CustomAdapter mAdapter;
mAdapter = new CustomAdapter(this,prgmNameList, prgmImages,h,w);
gridView.setAdapter(mAdapter);
}
}
else if(width<=480)
{
setContentView(R.layout.home_module);
gridView = (GridView) findViewById(R.id.gridView1);
gridView.setNumColumns(3);
h=150;
w=150;
CustomAdapter mAdapter;
mAdapter = new CustomAdapter(this,prgmNameList, prgmImages,h,w);
gridView.setAdapter(mAdapter);
}
else if(width >= 780)
{
setContentView(R.layout.home_module);
gridView = (GridView) findViewById(R.id.gridView1);
gridView.setNumColumns(4);
if(density <200)
{
h=200;
w=200;
CustomAdapter mAdapter;
mAdapter = new CustomAdapter(this,prgmNameList, prgmImages,h,w);
gridView.setAdapter(mAdapter);
}
else
{
h=200;
w=200;
CustomAdapter mAdapter;
mAdapter = new CustomAdapter(this,prgmNameList, prgmImages,h,w);
gridView.setAdapter(mAdapter);
}
}
希望这可以帮到你!
答案 2 :(得分:1)
创建一个不同的布局文件夹 RES /布局大/ layout.xml 你可以指定android的大小:columnWidth =“XYZdp”更大的东西 请参阅 http://developer.android.com/guide/practices/screens_support.html