Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在所有密度的相对布局中定位两个图像视图 我有一个相对论,在那里我放了两个图像,一个作为背景图像,另一个放在中间,但有一个朝向底部(见下图)。我有6种密度的图像。我的问题是,如果我把它拖到我想要的地方,它在所有密度下看起来都不一样_Android_Html_Layout_Background - Fatal编程技术网

Android 在所有密度的相对布局中定位两个图像视图 我有一个相对论,在那里我放了两个图像,一个作为背景图像,另一个放在中间,但有一个朝向底部(见下图)。我有6种密度的图像。我的问题是,如果我把它拖到我想要的地方,它在所有密度下看起来都不一样

Android 在所有密度的相对布局中定位两个图像视图 我有一个相对论,在那里我放了两个图像,一个作为背景图像,另一个放在中间,但有一个朝向底部(见下图)。我有6种密度的图像。我的问题是,如果我把它拖到我想要的地方,它在所有密度下看起来都不一样,android,html,layout,background,Android,Html,Layout,Background,我的问题是,如果我把它拖到我想要的地方,它在所有密度下看起来都不一样 假设您想要的位置稍微低于中心 您应该在drawables文件夹下创建am XML。。说。。例如shape.xml 下面是它的示例代码 res>drawables>shape.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:s

我的问题是,如果我把它拖到我想要的地方,它在所有密度下看起来都不一样

假设您想要的位置稍微低于中心

您应该在drawables文件夹下创建am XML。。说。。例如shape.xml

下面是它的示例代码

res>drawables>shape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
<corners android:radius="12px"/> 
<stroke android:width="2dip" android:color="#000000"/>  
</shape>
现在,您将在所有屏幕密度中获得
shape.xml
文件中设计的形状

PS:根据需要更改
shape.xml
文件的属性


如果需要背景图像,请将其设置为
RelativeLayout
,然后使用另一个imageview作为图像支架。如果我将第二个ImageView拖动到我想要的位置,那么“它在所有密度下看起来都不一样”是什么意思?在hdpi中,它与xxhdpi中的不一样。在不同的可绘制文件夹中,所有密度都有不同的图像。
我的问题是,如果我将其拖动到我想要的位置,所有密度的图像看起来都不一样。
-您想要它在哪里?
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
<corners android:radius="12px"/> 
<stroke android:width="2dip" android:color="#000000"/>  
</shape>
<ImageView 
android:id="@+id/rect_image" 
android:layout_height="150dp"   // change as per your requirements
android:layout_width="250dp"   // change as per your requirements
android:background="@drawable/shape"    // important one
android:paddingTop="75dp"   // position the shape as per your requirements here
android:src="@drawable/shape">
</ImageView>