Adding blank spaces to layout

前端 未结 14 1114
深忆病人
深忆病人 2021-01-30 04:53

I am trying to make empty lines within android. This is what I have been doing:

android:layout_width=\"fill_parent\" 
android:layout_height=\"wrap_content\" 
an         


        
相关标签:
14条回答
  • 2021-01-30 05:22
    <View
        android:layout_width="fill_parent"
        android:layout_height="30dp"
        android:background="#80000000">
    </View>
    
    0 讨论(0)
  • 2021-01-30 05:23

    The previous answers didn't work in my case. However, creating an empty item in the menu does.

    <menu xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:android="http://schemas.android.com/apk/res/android">
      ...
      <item />
      ...
    </menu>
    
    0 讨论(0)
  • 2021-01-30 05:26

    View if you need change background color , Space if not .

    that dosent mean you have to change view background .

    <View
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:background="@color/YOUR_BACKGROUND">
    </View>
    

    or Space

    <Space
            android:layout_width="match_parent"
            android:layout_height="20dp"
             />
    
    0 讨论(0)
  • 2021-01-30 05:29

    Below is the simple way to create blank line with line size. Here we can adjust size of the blank line. Try this one.

               <TextView
                android:id="@id/textView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textSize="5dp"/>
    
    0 讨论(0)
  • 2021-01-30 05:32

    Agree with all the answers......also,

        <TextView android:text=""
                  android:layout_width="match_parent"
                  android:layout_height="30dp"
                  android:layout_weight="2" />
    

    should work :) I am just messing with others as TextView is my favourite (waste of memory though!)

    0 讨论(0)
  • 2021-01-30 05:33

    An updated Answer: Since API 14, you can use "Space" View, as described in the documentation.

    Space is a lightweight View subclass that may be used to create gaps between components in general purpose layouts.

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