标签:android xml android-layout android-xml relativelayout
我有3个问题:
> imageView(白色瓷砖)看起来比gridView中的其他瓷砖大很多(这很奇怪,因为它只设置为5dp x 5dp)
>在我的editText上设置android:layout_alignParentRight =“true”,textView和imageView似乎没有将图像移动到右边
> android:layout_below =“@ id / sqwhite”似乎没有将我的editText放在我的textView下
(基本上:我需要在右下角正确调整这些尺寸,但我使用过的参数似乎没有任何效果.)
有任何想法吗?
<?xml version="1.0" encoding="utf-8"?>
<com.example.project.DragLayer xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:id="@+id/drag_layer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/black" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<GridView
android:id="@+id/image_grid_view"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.8"
android:background="@color/grid_background"
android:gravity="center"
android:horizontalSpacing="2dip"
android:numColumns="@integer/num_columns"
android:stretchMode="columnWidth"
android:verticalSpacing="2dip" />
<RelativeLayout
android:id="@+id/bottom_part"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_weight="0.2"
android:background="@android:color/black"
android:orientation="horizontal"
android:weightSum="1.0" >
<Button
android:id="@+id/button_add_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:onClick="onClickAddImage"
android:text="Add image" />
<com.example.project.DeleteZone
android:id="@+id/delete_zone_view"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:src="@drawable/delete_zone" />
<FrameLayout
android:id="@+id/image_source_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/sqwhite"
android:layout_width="5dp"
android:layout_height="5dp"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginRight="5dp" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/sqwhite"
android:layout_marginRight="5dp" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/editText1"
android:layout_marginRight="5dp"
android:text=""
android:textColor="@android:color/white" />
</RelativeLayout>
</FrameLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</com.example.project.DragLayer>
解决方法:
好的,我已经尝试过你的布局了,首先,你不需要在linearlayout中使用xmlns
关于其余的:
1)我猜sqwhite是大白瓦.如果是,我没有看到任何src或背景,但如果你正在使用它,使用src可能会拉伸视图.
2)布局就像我复制它一样,确实将所有项目移到右边,不知道那里发生了什么.
3)我看到这也正常.
其他的建议:
– 框架布局是不必要的
– 您可以对image_source_frame使用简单的线性布局
这就是我做的.虽然我更改了对项目的一些引用,因此我可以使用图形布局,因此请将其更改回来.这样的布局似乎解决了你所有的3个问题.
<?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="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<GridView
android:id="@+id/image_grid_view"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.8"
android:background="#FFFF0000"
android:gravity="center"
android:horizontalSpacing="2dip"
android:numColumns="3"
android:stretchMode="columnWidth"
android:verticalSpacing="2dip" />
<RelativeLayout
android:id="@+id/bottom_part"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_weight="0.2"
android:background="@android:color/black"
android:orientation="horizontal"
android:weightSum="1.0" >
<Button
android:id="@+id/button_add_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:onClick="onClickAddImage"
android:text="Add image" />
<com.example.project.DeleteZone
android:id="@+id/delete_zone_view"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:src="#FF00FF00" />
<LinearLayout
android:id="@+id/image_source_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:orientation="vertical"
android:gravity="right" >
<ImageView
android:id="@+id/sqwhite"
android:layout_width="5dp"
android:layout_height="5dp"
android:layout_gravity="right"
android:layout_marginRight="5dp" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:text=""
android:textColor="@android:color/white" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
标签:android,xml,android-layout,android-xml,relativelayout 来源: https://codeday.me/bug/20190917/1809527.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。