如题所述,我在界面的底部需要放置3个功能按钮,用图标表示,所以用的imagebutton控件。我想要的效果是,三个imagebutton能够显示在平板的底部居中位置,且有一定的间隙,关键是背景图片不能拉伸,要居中的显示在每个imagebutton的中间,请问该怎么布局啊??之前我对每个imagebutton用android:layout_weight="0.33" ,这样三个按钮拉伸, 各占1/3的长度,但是背景图片也被拉伸了....
希望得到大家的帮助,谢谢

解决方案 »

  1.   

    不清楚楼主的要求…楼主是要让按钮的可点击区域比图片大还是说只是简单的把3张图片作为3个按钮放在底行居中?如果是第一种,楼主把图片加上多余的边框将图片撑大就行了。第二种的话把3个按钮写在一个layout里面然后让这个layout在底行居中行不?
      

  2.   

    设置 android:layout_weight="0.33" 的同时 设置 每个 ImageButton 的 padding和layout_margin 属性。并且要设置 layout_width 和layout_height 设置固定值
      

  3.   

    设置padding 是按钮的位置吧,关键里面的backgroundImage拉伸了,我不需要它拉伸,拉伸就变形了
      

  4.   

    layout_weight 设置 view 在layout中的比例
    如果layout_height 或者layout_width 设置为0dip 那么会自动拉伸view, 如果layout_height 或者layout_width设置了固定值 ,就不会拉伸
      

  5.   

    用相对布局,设置好第一个按钮位置,然后2,3按钮在右边,设置相应的margin,应该能行吧
      

  6.   


    <TableLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="0,1,2">
    <TableRow
    android:gravity="center_horizontal">
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal">
    <ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/icon"></ImageButton>
    </LinearLayout>
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal">
    <ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/icon"></ImageButton>
    </LinearLayout>
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal">
    <ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/icon"></ImageButton>
    </LinearLayout>
    </TableRow>
    </TableLayout>
    LZ试试这个行不
      

  7.   

    </LinearLayout>可以实现,但是还是相对布局好些
      

  8.   

    iamgeButton ,用backgroundImage,不要用Image,否则不透明