fragment上面显示actionbar



上面那个红框里面是我想要实现的,但是找了好久都没有找到,

我的主要布局文件如下[activity_main.xml]:



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context=".MyActivity">
    
----------这一段报错,是我自己添加的
<android.support.v7.app.ActionBar
            android:id="@+id/actionbar"
            app:title="@string/app_name"
            style="@style/ActionBar"
            />
----------这一段报错,是我自己添加的

    <com.w1520.xianledemo.IconTabPageIndicator
            android:id="@+id/indicator"
            android:layout_alignParentBottom="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    <android.support.v4.view.ViewPager
            android:layout_above="@id/indicator"
            android:id="@+id/view_pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
</RelativeLayout>


styles.xml


<resources>

    <!-- ActionBar 样式 -->
    <style name="ActionBar"
           parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:background">#cccccc</item>
        <item name="android:textColor">#000000</item>
    </style>


    <style name="AppTheme" parent="Theme.AppCompat.Light">
    
        <item name="tabView">@style/TabView</item>
        <item name="tabPageIndicator">@style/TabIndicator</item>
    </style>
    <style name="TabIndicator"/>
    <style name="TabView">
        <item name="android:addStatesFromChildren">true</item>
        <item name="android:orientation">vertical</item>
        <item name="android:gravity">bottom|center_horizontal</item>
        <item name="android:layout_width">0dp</item>
        <item name="android:background">@android:color/white</item>
        <item name="android:layout_height">match_parent</item>
    </style>

</resources>






主activity 实现:


public class MainActivity extends FragmentActivity {

    private ViewPager mViewPager;
    private IconTabPageIndicator mIndicator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        /*ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);*/
        initViews(savedInstanceState);
    }
}


AndroidManifest.xml



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xxxx.app" >
    <uses-sdk android:minSdkVersion="14"/>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>



最好有个示例,谢谢
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值