今天在看一些源码的时候,发现人家设置标题都不用样式布局文件,看了后感觉还是蛮方便的,

具体操作如下:

super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.share);

添加代码

requestWindowFeature(Window.FEATURE_NO_TITLE);

设置不要标题,

然后在配置文件添加配置如下:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical" >        <RelativeLayout        android:id="@+id/rl_top"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_alignParentTop="true" >        <TextView            android:layout_width="fill_parent"            android:layout_height="44dp"            android:background="#486a9a"            android:gravity="center"            android:text="分享例子"            android:textColor="@android:color/white"            android:textSize="18sp" />    </RelativeLayout>        <Button        android:id="@+id/share"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="分享" /></LinearLayout>  



此操作容易控制,但是布局多的话会写很多代码。

更多相关文章

  1. 没有一行代码,「2020 新冠肺炎记忆」这个项目却登上了 GitHub 中
  2. Android(安卓)用Animation-list实现逐帧动画
  3. Android界面设计的一点体会
  4. Android(安卓)反编译apk
  5. Android(安卓)在代码中动态设置字体颜色需要注意的问题
  6. [转]Android(安卓)UI学习 - Tab的学习和使用
  7. android studio 多渠道打包
  8. Android以太网固定ip
  9. Android中实现ListView横向滑动

随机推荐

  1. Android(安卓)应用架构组件(Architecture
  2. android browser 的几个小feature (一)
  3. android binder机制之--(我是binder)
  4. 视频教程-Android(安卓)Material Design
  5. Android中Context详解
  6. android studio 使用android:drawableTop
  7. Android(安卓)监控程序安装和删除的实现
  8. 1.4EditText
  9. [Android]App Resource 动态 overlay 机
  10. android - 为安全而设计 - 2 - 开发文档