今天将酝酿已久的一个Android课程设计写上CSDN记录下来,可能过程一些错误的地方都忘记了,真不应该那么迟才写上来。因为近端时间都在学习数学所有把精力都没有集中在Android。

我先把我做得效果给甩上图来。

android 自定义标题栏和自定义下拉选项PopupWindow_第1张图片

是一个可以发布文字和图文、视频的一个小功能的App,中间是ListView,然后适配器adapter。

第一个要说的是 自定义标题栏

android 自定义标题栏和自定义下拉选项PopupWindow_第2张图片

在MainActivity.java中写到

 protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);//自定义标题栏    setContentView(R.layout.activity_main);        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mycustomtitle);//使用布局文件来定义标题栏

新建了个xml文件:mycustomtitle.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="fill_horizontal" android:orientation="horizontal" android:gravity="center" android:background="#FFF">    <TextView android:id="@+id/header_text" android:layout_weight="1" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_toLeftOf="@+id/header_right_btn" android:text="Mind" android:layout_marginLeft="5dp" android:textSize="20sp" android:gravity="center" android:paddingLeft="40dp" android:textStyle="bold" android:textColor="#21cbc1" android:singleLine="true" />    <RelativeLayout  android:id="@+id/rl_topbar" android:layout_width="1dp" android:layout_height="1dp" android:gravity="center_vertical" >    </RelativeLayout>    <ImageButton  android:id="@+id/addbtn" android:layout_width="30dp" android:layout_height="30dp" android:layout_marginRight="10dp" android:background="@drawable/add" /></LinearLayout>

RelativeLayout在里面只是起到定位的功能,在以上没有什么作用。

这是style文件的内容

    <style name="WindowTitleBackground" >        <item name="android:background">#FFF</item>    </style>    <style name="MyTheme" parent="android:Theme">        <item name="android:windowTitleSize">60dp</item>        <item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground</item>    </style>

这是AndroidManifest.xml的要修改和填写的内容

    <activity  android:name=".MainActivity" android:label="Mind" android:screenOrientation="portrait" android:theme="@style/MyTheme">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>

android:theme=”@style/MyTheme” 主要是这句 应用主题。

接下来是第二个内容:
android 自定义标题栏和自定义下拉选项PopupWindow_第3张图片

这是点击按钮,显示的View. 这个是在网上学习的,至于原文章我也忘记了。后来我有修改过啦,他原本只是实现了功能,美化方面就没有注意了。

代码在过两天再写吧。眼睛都不舒服了。

更多相关文章

  1. [Android中级]使用Commons-net-ftp来实现FTP上传、下载的功能
  2. Android:Button同时设置OnLongClick、OnClick模拟相机长按聚焦 短
  3. Android adb功能使用方法
  4. 22、Android之 使用手机的 GPS 功能
  5. android解析XML文件的三方法之SAX
  6. Android静默安装实现方案,仿360手机助手秒装和智能安装功能 .
  7. android文件下载与保存
  8. 在android中使用PrinterShare实现蓝牙打印功能

随机推荐

  1. > need update
  2. error
  3. AudioTrack::createTrack()
  4. Android(安卓)Studio项目目录结构
  5. setImageResource(),setImageBitmap()和se
  6. android ffmpeg compile error fix notes
  7. android ——设置圆形图片
  8. Android(安卓)Color Palette
  9. android wifi测试小程序
  10. THE 10-STEP GUIDE TO ANNOTATION PROCES