Android Layout_width & Layout_height, How It Works?
Solution 1:
The layout_width
and layout_height
properties of a view are intended to be used by its parent container. Some containers ignore one or both of these; most honor them. You need to consult the documentation of the container (in your case, SlidingDrawer) to understand how the values will be used.
You don't show the complete main.xml, so it's hard to say exactly what's going wrong. It would also help if you posted an image of what's wrong.
EDIT
After seeing your complete layout, I think that the basic problem here is that you are using a LinearLayout to contain the SlidingDrawers. As the docs for SlidingDrawer note, they need to be in either a FrameLayout or a RelativeLayout (actually, any container that allows multiple views to sit on top of one another).
Another possibility is that the second SlidingDrawer is being placed directly under the first one. Try changing the size of the second button (e.g., make the text longer) and see if it pokes out on either side of button 1.
Solution 2:
fill_parent = match_parent, and it means that it takes the width or height (which ever property it is being specified as) of the "parent" container
wrap_content means that the height or width takes on the height or width of the "child"
You want to use weights instead of using match_parent or wrap_content typically.
When you do use weights you want to set the width to 0dp.
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/main"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="vertical" ><LinearLayoutandroid:id="@+id/lowerLayout"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:weightSum="1.0" ><LinearLayoutandroid:id="@+id/headerLayout"android:layout_width="0dp"android:layout_height="wrap_content"android:orientation="horizontal"android:layout_weight=".7" ><Buttonandroid:id="@+id/previousMonthButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Previous" /><TextViewandroid:id="@+id/monthName"android:layout_width="0dip"android:layout_height="wrap_content"android:text="Large Text"android:layout_weight="1"android:textAppearance="?android:attr/textAppearanceLarge"android:gravity="center_horizontal" /><Buttonandroid:id="@+id/nextMonthButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Next" /></LinearLayout><LinearLayoutandroid:id="@+id/lowerLayout3"android:layout_width="0dp"android:layout_height="wrap_content"android:orientation="horizontal"android:layout_weight=".3" ><Buttonandroid:id="@+id/addEvent"android:layout_width="wrap_content"android:layout_height="wrap_content" /></LinearLayout></LinearLayout><LinearLayoutandroid:id="@+id/lowerLayout2"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:weightSum="1.0" ><LinearLayoutandroid:id="@+id/monthView"android:layout_width="0dp"android:layout_height="match_parent"android:orientation="vertical"android:layout_weight=".7" ></LinearLayout><ListViewandroid:id="@+id/listView1"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight=".3" ></ListView></LinearLayout></LinearLayout>
Solution 3:
I think you trying to add 2 Sliding Drawer.
The size of the SlidingDrawer defines how much space the content will occupy once slid out so SlidingDrawer should usually use match_parent for both its dimensionsin this case one overlap other one so you can't see the handler 2 .
If you set visibility "gone" of first SlidingDrawer you can see the Other one .
Update
Hi ,
Please try this code may it help you
<?xml version="1.0" encoding="utf-8"?>
<SlidingDrawerandroid:id="@+id/slidingDrawer1"android:layout_width="fill_parent"android:layout_height="0dip"android:layout_weight="1"android:content="@+id/content1"android:handle="@+id/handle1" ><Buttonandroid:id="@+id/handle1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Handle 1" ></Button><LinearLayoutandroid:id="@+id/content1"android:layout_width="fill_parent"android:layout_height="wrap_content"android:background="#FF444444"android:gravity="center"android:orientation="vertical" ><Buttonandroid:id="@+id/item1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Handle 1 Item 1" ></Button></LinearLayout></SlidingDrawer>
Post a Comment for "Android Layout_width & Layout_height, How It Works?"