我有3个问题:
(白色瓷砖)ImageView的出现要比在GridView(这很奇怪,因为它只是设置为5DP x 5DP)其他瓷砖较大 设置机器人:我EDITTEXT layout_alignParentRight =真,TextView的和ImageView的似乎没有图像向右移动 安卓layout_below =@ ID / sqwhite似乎并没有把在我的TextView我EDITTEXT(基本上是:我需要得到这些在右下角正确的尺寸,但没有我所用的参数似乎产生任何影响。)
任何想法?
< XML版本=1.0编码=UTF-8&GT?;
< com.example.project.DragLayer的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:启动=http://schemas.android.com/apk/res/com.android.launcher
机器人:ID =@ + ID / drag_layer
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:背景=@机器人:彩色/黑白>
<的LinearLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直>
<的LinearLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:方向=垂直
机器人:weightSum =1.0>
< GridView控件
机器人:ID =@ + ID / image_grid_view
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =FILL_PARENT
机器人:layout_weight =0.8
机器人:背景=@色/ grid_background
机器人:重力=中心
机器人:horizontalSpacing =2DIP
机器人:为numColumns =@整数/ NUM_COLUMNS
机器人:stretchMode =columnWidth中
机器人:verticalSpacing =2DIP/>
< RelativeLayout的
机器人:ID =@ + ID / bottom_part
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:layout_centerHorizontal =真
机器人:layout_weight =0.2
机器人:背景=@机器人:彩色/黑白
机器人:方向=横向
机器人:weightSum =1.0>
<按钮
机器人:ID =@ + ID / button_add_image
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_centerHorizontal =真
机器人:的onClick =onClickAddImage
机器人:文本=添加图片/>
< com.example.project.DeleteZone
机器人:ID =@ + ID / delete_zone_view
机器人:layout_width =60dp
机器人:layout_height =60dp
机器人:layout_gravity =中心
机器人:SRC =@可绘制/ delete_zone/>
<的FrameLayout
机器人:ID =@ + ID / image_source_frame
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =0.5>
< RelativeLayout的
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
>
< ImageView的
机器人:ID =@ + ID / sqwhite
机器人:layout_width =5DP
机器人:layout_height =5DP
机器人:layout_alignParentRight =真
机器人:layout_gravity =右
机器人:layout_marginRight =5DP/>
<的EditText
机器人:ID =@ + ID / editText1
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_below =@ ID / sqwhite
机器人:layout_marginRight =5DP>
<不是requestFocus />
< /的EditText>
<的TextView
机器人:ID =@ + ID / textView1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_below =@ ID / editText1
机器人:layout_marginRight =5DP
机器人:文本=
机器人:文字颜色=@机器人:彩色/白/>
< / RelativeLayout的>
< /的FrameLayout>
< / RelativeLayout的>
< / LinearLayout中>
< / LinearLayout中>
< /com.example.project.DragLayer>
解决方案
好了,我想你的布局,首先,你不需要的xmlns中的LinearLayout
有关其他地区:
1)我猜sqwhite是大白色瓷砖。如果是这样,我看不出有任何的src或背景,但使用的src如果你使用它可能会伸展的看法。
2),就像我复制它的布局,不会将所有物品的权利,真的不知道发生了什么在那里。
3)我认为这也正常。
其他评论:
-The的FrameLayout是不必要的。
- 你可以用一个简单的LinearLayout的image_source_frame
下面是我所做的。虽然我换了几个引用到您的项目,所以我可以使用图形化的布局,所以改回来。这样的布局,因为它是似乎解决您所有的3个问题在这里。
< XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直>
<的LinearLayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:方向=垂直
机器人:weightSum =1.0>
< GridView控件
机器人:ID =@ + ID / image_grid_view
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =FILL_PARENT
机器人:layout_weight =0.8
机器人:后台=#FFFF0000
机器人:重力=中心
机器人:horizontalSpacing =2DIP
机器人:为numColumns =3
机器人:stretchMode =columnWidth中
机器人:verticalSpacing =2DIP/>
< RelativeLayout的
机器人:ID =@ + ID / bottom_part
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:layout_centerHorizontal =真
机器人:layout_weight =0.2
机器人:背景=@机器人:彩色/黑白
机器人:方向=横向
机器人:weightSum =1.0>
<按钮
机器人:ID =@ + ID / button_add_image
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_centerHorizontal =真
机器人:的onClick =onClickAddImage
机器人:文本=添加图片/>
< com.example.project.DeleteZone
机器人:ID =@ + ID / delete_zone_view
机器人:layout_width =60dp
机器人:layout_height =60dp
机器人:layout_gravity =中心
机器人:SRC =#FF00FF00/>
<的LinearLayout
机器人:ID =@ + ID / image_source_frame
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =0.5
机器人:方向=垂直
机器人:重力=权与GT;
< ImageView的
机器人:ID =@ + ID / sqwhite
机器人:layout_width =5DP
机器人:layout_height =5DP
机器人:layout_gravity =右
机器人:layout_marginRight =5DP/>
<的EditText
机器人:ID =@ + ID / editText1
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginRight =5DP>
<不是requestFocus />
< /的EditText>
<的TextView
机器人:ID =@ + ID / textView1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginRight =5DP
机器人:文本=
机器人:文字颜色=@机器人:彩色/白/>
< / LinearLayout中>
< / RelativeLayout的>
< / LinearLayout中>
< / LinearLayout中>
I have 3 issues:
The imageView (of a white tile) appears MUCH larger than the other tiles in the gridView (which is strange because it's only set to 5dp x 5dp) setting android:layout_alignParentRight="true" on my editText, textView and imageView do not seem to move the image to the right android:layout_below="@id/sqwhite" does not seem to place my editText under my textView(Basically: I need to get these to be sized correctly in the bottom right hand corner but none of the parameters I've used seem to have any effect.)
Any ideas?
<?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>
解决方案
OK, I've tried your layout, and first of all, you don't need the xmlns in the linearlayout
about the rest:
1) I'm guessing sqwhite is the big white tile. if it is, I don't see any src or background, but the use of src if you're using it might stretch the view.
2) The layout just as I copied it, does move all items to the right, don't really know what's happening there.
3)I see this also working properly.
Other comments:
-The framelayout is unnecessary
-You can use a simple linearlayout for the image_source_frame
Here's what I did. Though I changed a few references to your project so I could use the graphical layout, so change them back. This layout as it is seems to solve all your 3 problems here.
<?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>