开发者

Why is there a black bar at the bottom of my layout?

I want to move the bottom bar in my layout all the way to the bottom of the screen, but there is a black bar at the bottom. How can I remove this black space so that my application fills the screen?

Here the code :

<?xml version="1.0" encoding="utf-8" ?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:background="@drawable/back1" android:layout_height="wrap_content">      
    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="40dip"
    android:gravity = "center"
    >
    />      
    </LinearLayout>
    <LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:background="#48250F"
    android:gravity="center">           
    <ImageView android:id="@+id/detail_view_1"
     android:layout_width="200dip" 
     android:layout_height="240dip"

     android:layout_gravity="center"
     android:paddingTop="30dip"
     android:paddingBottom="10dip" />
      <TextView android:id="@+id/detail_name" android:layout_width="wrap_content"
       android:layout_height="wrap_content" android:paddingLeft="2dip"
       android:paddingTop="10dip"
       android:paddingBottom="10dip"
       android:textStyle="bold"
      android:textColor="#FFFFFF"
      />
      <Button
        android:id="@+id/btn_facebook"
        android:background="@drawable/button_color_selector"
        android:layout_width="120dip" 
        android:layout_height="25dip"
        android:text="facebook"
        android:textColor = "#FFFFFF"                    
        android:layout_marginTop="10dip"
        android:layout_marginBottom="5dip"
        />
        <Button
        android:id="@+id/btn_email"
        android:background="@drawable/button_color_selector"
        android:layout_width="120dip" 
        android:layout_height="25dip"
        android:text="email"
        android:textColor = "#FFFFFF"                    
        android:layout_marginTop="10dip"
        android:layout_marginBottom="5dip"/>
    </LinearLayout>
    <TableLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android开发者_JAVA技巧:layout_height="wrap_content"
    android:gravity = "center"
     android:layout_gravity="bottom"
    android:stretchColumns="1,3,5,7">
     <TableRow>
        <Button
        android:id="@+id/image21"
        android:background="@drawable/flavors"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:padding= "3dip"
         android:layout_gravity="bottom"
        />      
        <TextView android:id="@+id/text_empty1" android:layout_width="wrap_content" />
        <Button
        android:id="@+id/image22"
        android:background="@drawable/calendar"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:paddingLeft = "1dip"
        android:paddingRight = "1dip"
         android:layout_gravity="bottom"
        />
        <TextView android:id="@+id/text_empty2" android:layout_width="wrap_content" />
        <Button
        android:id="@+id/image23"
        android:background="@drawable/fun"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingLeft = "1dip"
        android:paddingRight = "1dip"
         android:layout_gravity="bottom"
        />
        <TextView android:id="@+id/text_empty3" android:layout_width="wrap_content" />
        <Button
        android:id="@+id/image24"
        android:background="@drawable/locations"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingLeft = "1dip"
        android:paddingRight = "1dip"
         android:layout_gravity="bottom"
        />
        <TextView android:id="@+id/text_empty4" android:layout_width="wrap_content" />
        <Button
        android:id="@+id/image25"
        android:background="@drawable/gifts"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingLeft = "1dip"
        android:paddingRight = "1dip"
         android:layout_gravity="bottom"
        />
     </TableRow>
    </TableLayout>
</LinearLayout>

Why is there a black bar at the bottom of my layout?


Give android:height attribute of linear layout and table layout to fill_parent. It may work.


Put the <TableView> for the menu bar inside a <RelativeView android:layout_height="fill_parent" android:layout_width="fill_parent" android:gravity="bottom"> That should fix your problem. GL


try this :

<TableLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity = "center_horizontal"
 android:layout_gravity="bottom"
android:stretchColumns="1,3,5,7">


Basically what you want to do is change the outermost layout to a relativelayout and have the bottom-most table layout thingie changed to android:layout_alignParentBottom="true"

<?xml version="1.0" encoding="utf-8" ?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:background="@color/red" android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal"
    android:layout_width="fill_parent" android:layout_height="40dip"
    android:gravity="center">
    />      
</LinearLayout>
<LinearLayout android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:layout_weight="1" android:background="#48250F"
    android:gravity="center">
    <ImageView android:id="@+id/detail_view_1"
        android:layout_width="200dip" android:layout_height="240dip"

        android:layout_gravity="center" android:paddingTop="30dip"
        android:paddingBottom="10dip" />
    <TextView android:id="@+id/detail_name" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:paddingLeft="2dip"
        android:paddingTop="10dip" android:paddingBottom="10dip"
        android:textStyle="bold" android:textColor="#FFFFFF" />
    <Button android:id="@+id/btn_facebook" android:background="@color/black"
        android:layout_width="120dip" android:layout_height="25dip"
        android:text="facebook" android:textColor="#FFFFFF"
        android:layout_marginTop="10dip" android:layout_marginBottom="5dip" />
    <Button android:id="@+id/btn_email" android:background="@color/black"
        android:layout_width="120dip" android:layout_height="25dip"
        android:text="email" android:textColor="#FFFFFF"
        android:layout_marginTop="10dip" android:layout_marginBottom="5dip" />
</LinearLayout>
<TableLayout android:gravity="center" android:id="@+id/tableLayout1" android:stretchColumns="1,3,5,7" android:layout_width="fill_parent" android:orientation="horizontal" android:layout_height="wrap_content" android:layout_alignParentBottom="true">
    <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">
        <Button android:id="@+id/image21" android:text="Button" android:background="@color/black" android:layout_gravity="bottom" android:layout_width="fill_parent" android:padding="3dip" android:layout_height="wrap_content"></Button>
        <TextView android:id="@+id/text_empty1" android:text="TextView" android:layout_height="wrap_content" android:layout_width="wrap_content"></TextView>
        <Button android:id="@+id/image22" android:text="Button" android:paddingLeft="1dip" android:background="@color/black" android:paddingRight="1dip" android:layout_gravity="bottom" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
        <TextView android:id="@+id/text_empty2" android:text="TextView" android:layout_height="wrap_content" android:layout_width="wrap_content"></TextView>
        <Button android:id="@+id/image23" android:text="Button" android:paddingLeft="1dip" android:background="@color/black" android:paddingRight="1dip" android:layout_gravity="bottom" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
        <TextView android:id="@+id/text_empty3" android:text="TextView" android:layout_height="wrap_content" android:layout_width="wrap_content"></TextView>
        <Button android:id="@+id/image24" android:text="Button" android:paddingLeft="1dip" android:background="@color/black" android:paddingRight="1dip" android:layout_gravity="bottom" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
        <TextView android:id="@+id/text_empty4" android:text="TextView" android:layout_height="wrap_content" android:layout_width="wrap_content"></TextView>
        <Button android:id="@+id/image25" android:text="Button" android:paddingLeft="1dip" android:background="@color/black" android:paddingRight="1dip" android:layout_gravity="bottom" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
    </TableRow>
</TableLayout>
</RelativeLayout>


try setting the android:layout_height attribute of the outermost LinearLayout to fill_parent

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜