Android XML Layout Parameters Do Not Function As Expected

前端 未结 1 714
走了就别回头了
走了就别回头了 2020-11-28 00:02

\"enter

I have 3 issues:

  1. The imageView (of a white tile) appears MUCH la
相关标签:
1条回答
  • 2020-11-28 00:36

    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>
    
    0 讨论(0)
提交回复
热议问题