Android: How to fill RelativeLayout to full width of screen?

前端 未结 6 803
长情又很酷
长情又很酷 2021-01-01 16:19

I am creating an Android app which has a main RelativeLayout and some LinearLayout within it.

Now i have this problem. When dragging items to the editor, e.g. a Line

相关标签:
6条回答
  • 2021-01-01 16:54

    The space between the blue part and the "end of the screen". On the sides and above the part where the back button and home button are.

    Remove the padding from the root RelativeLayout.

    0 讨论(0)
  • 2021-01-01 16:59

    Don't use fill_parent as it is deprecated. Instead to your RelativeLayout set

    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    

    Then, to the list view that you want to fill the rest of the screen, you can set this tags

    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    

    By doing so, you are telling the XML that you want your ListView to do what fill_parent used to do in previous versions of Android.

    Kind regards!

    0 讨论(0)
  • 2021-01-01 17:03

    Try

    <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:orientation="vertical>
       // Other views within the linear layout
    </LinearLayout>
    

    I suppose you are using Eclipse. Personally, I hate the Graphical Editor of Eclipse and I usually write the XML code directly because working with the editor is a real pain

    0 讨论(0)
  • 2021-01-01 17:04

    you should try something like the following :

    <LinearLayout
        android:id="@+id/itemDetailLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" 
         >
    
    ...
    
    
    </LinearLayout>
    

    what i mean you should do this :

    android:layout_width="fill_parent"
    

    for every LinearLayout that you want its width to fill_parent .

    FILL_PARENT means that the view wants to be as big as its parent as mentioned in the documentation .

    and please give me some feedback

    Hope That Helps .

    0 讨论(0)
  • 2021-01-01 17:05

    Removing padding makes the linear layout fit the entire screen of the device

    0 讨论(0)
  • 2021-01-01 17:18

    Replace this:

       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
    

    With

       android:layout_width="match_parent"
       android:layout_height="wrap_content"
    

    into your LinearLayout or Remove all the Padding from main RelativeLayout

    0 讨论(0)
提交回复
热议问题