zoukankan      html  css  js  c++  java
  • android使用.9图作为背景,内容不能居中的问题解决方案

    在xml中使用.9图作为背景,内容不能居中,试了好多方法最后,加一个属性就ok了。

    android:padding:0dip;

    解析:.9图作为背景时,不可拉伸的部分就相当于该空间的padding距离

    我的这个.9图只是左边可以拉伸的,右边大概80px是固定的,不可拉伸的。所以就相当于右边设置了padding距离。

    我们也不能设置一个反向的padding,因为app需要安装在不同分别率的设备上,所以这个值又是不固定的。

    <Button
    android:id="@+id/button_1"
    style="?android:attr/buttonBarStyle"
    android:layout_width="fill_parent"
    android:layout_height="63dip"
    android:layout_marginTop="15dip"
    android:background="@drawable/newi_bg"
    android:gravity="center"
    android:padding="0dip"
    android:text="@string/button_text"
    android:textColor="#707070"
    android:textSize="18sp" />

    OK!

  • 相关阅读:
    Ubuntu中的vsftpd配置
    Ubuntu学习-增加更新源及安装软件及卸载软件
    Ubuntu16.04下安装sublime text3
    需要读的书
    同一机器 部署 两个 jboss
    log4j 总结 精华
    oracle 笔记
    oracle 用户 多个表空间
    json
    json 基础
  • 原文地址:https://www.cnblogs.com/yuan1225/p/4449431.html
Copyright © 2011-2022 走看看