ver*_*one 4 xml android relativelayout imageview
我在RelativeLayout中有一个ImageView.ImageView的源是一个.png文件.问题是,在具有不同分辨率的设备上测试时,android不会向上或向下缩放图像.我在android文档中读到android自动向上或向下缩放图像以填充屏幕,但这不会发生.可能是什么问题呢?我是android的新手,抱歉,如果这个问题很愚蠢,我搜索了很多,但找不到解决方案.
编辑:XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ImageView
android:id="@+id/imageview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:clickable="false"
android:scaleType="fitXY"
android:contentDescription="@string/p"
android:src="@drawable/example" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
编辑2:我需要拉伸的XML布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:gravity="center">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView1"
android:clickable="false"
android:contentDescription="@string/p"
android:src="@drawable/volbar" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:layout_alignParentLeft="true"
android:contentDescription="@string/p"
android:src="@drawable/head" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageView1"
android:layout_alignParentLeft="true"
android:layout_marginBottom="33dp"
android:layout_marginRight="19dp"
android:text="@string/press_to_update" />
<ImageView
android:id="@+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView2"
android:clickable="false"
android:contentDescription="@string/p"
android:src="@drawable/frag11"
/>
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView9"
android:clickable="false"
android:contentDescription="@string/p"
android:src="@drawable/base" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
sti*_*ike 10
使用android:scaleType="fitXY"布局
编辑
如果你想让图像占据整个屏幕然后使用
android:layout_width="match_parent"
android:layout_height="match_parent"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8552 次 |
| 最近记录: |