试题一layout和配置


/******************************************************************/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.yuekao.MainActivity">

    <android.support.design.widget.TabLayout
        android:id="@+id/tablayout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        app:tabMode="scrollable"
        app:tabSelectedTextColor="#ff0000"
        ></android.support.design.widget.TabLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></android.support.v4.view.ViewPager>


</LinearLayout>
 
/*******************************************************************/item.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:orientation="vertical"

    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:id="@+id/textitem"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <ImageView
            android:id="@+id/imageitem"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:scaleType="fitXY" />


    </LinearLayout>


</LinearLayout>

/**************************************************************/mfragmnet.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:orientation="vertical">

    <com.limxing.xlistview.view.XListView
        android:id="@+id/xlistview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"></com.limxing.xlistview.view.XListView>

</LinearLayout>

/******************************************************************/secondactivity.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:orientation="vertical">

    <TextView
        android:id="@+id/tv1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="zmkjnfvjdfnvjdfvldf"

        />

    <com.github.chrisbanes.photoview.PhotoView
        android:id="@+id/iv1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />


</LinearLayout>

 
/***********************************************************/配置
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.yuekao">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


    <application
        android:name=".App"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".SecondActivity" />
    </application>

</manifest>

 
 
 
 
 
 
 
 
 
 
 
 
 
 

                
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果要配置umi的tabslayout,首先需要在umi项目中安装antd-mobile组件库。然后在页面文件中引入Tabs组件,并配置TabPane子组件。可以通过设置Tabs组件的defaultActiveKey属性来指定默认展示的tab,通过onChange属性来监听tab切换的事件。在TabPane子组件中,可以设置tab属性来指定tab的名称,也可以通过key属性来给每个TabPane设置一个唯一的key值。除此之外,还可以设置disabled属性来禁用某个tab。 在umi框架中,可以通过model来管理tab的状态。可以创建一个tabModel,用来存储当前选中的tab以及处理tab切换的逻辑。通过connect方法将tabModel与页面组件关联起来,这样就可以在页面组件中通过this.props.dispatch来修改tab的状态。 在umi中,可以通过配置路由来配置tabslayout。可以使用withRouter方法将Tabs组件包裹在路由组件中,然后在路由配置文件中设置路由和对应的组件。在Tabs组件中,可以通过props.history.location.pathname来获取当前路由的路径,根据这个路径来设置defaultActiveKey属性,从而实现不同的路由对应不同的tab。 总之,umi中配置tabslayout主要是通过antd-mobile组件库提供的Tabs组件,配合umi框架提供的路由配置和model管理,来实现tab切换和状态管理。需要在页面文件中引入Tabs组件,配置TabPane子组件,使用model管理tab状态,以及在路由配置中设置tab对应的路由和组件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值