设置图库大小android
问题描述:
我在android中设置了一个图库大小的问题。我想设置画廊(如设备的屏幕的一半),我使用此代码的大小:设置图库大小android
int width = (int) getResources().getDimension(R.dimen.image_height);
int height = (int) getResources().getDimension(R.dimen.image_width);
iv.setLayoutParams(new Gallery.LayoutParams(width, height));
iv.setLayoutParams(new Gallery.LayoutParams(30, 40)); `
和main.xml中:
<?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:orientation="vertical" >
<TextView
android:id="@+id/mySelection"
android:layout_width="fill_parent"
android:layout_height="
android:background="#ffffff"
android:textSize="20px"
android:textStyle="bold" />
<Gallery
android:id="@+id/myGallery"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:gravity="bottom"
android:spacing="
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="0.46" />
</LinearLayout>`
而且,设定深度和高度在images.xml
文件不工作。
答
UR高度不工作怎么把üdidnt再次给value..see我们的代码..并设置GridView控件使用的尺寸此代码:
Display display = activity.getWindowManager().getDefaultDisplay();
int halfDeviceWidth = display.getWidth()/2;
int halfDeviceHeight = display.getHeight()/2;
iv.setLayoutParams(new Gallery.LayoutParams(halfDeviceWidth, halfDeviceHeight));
使用此代码..
其中i必须给的价值...我不明白...请给一些解释...谢谢你..... –
代码你已经写删除,并把这段代码。你应该在'onCreate(Bundle savedInstanceState)'''''''activity'方法中得到这个ppt。 –
它声明错误,没有定义活动..如何定义它..请告诉我... –