学习安卓开发第八天【滚动视图】【滑动视图实例】【选项卡】

ScrollView:滚动视图
HorizontalScrollView:水平滚动视图
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    tools:context=".MainActivity">

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        >
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textSize="75sp"
            android:text="@string/content"
            ></TextView>


    </ScrollView>
</RelativeLayout>
<resources>
    <string name="app_name">guodongshitu</string>
    <string name="content">鹌盲从山东次男盗女娼擦基础上大V精虫上脑总成绩撒娇覅哇哦if我护肤后入阿发吧京东商城现在没事的农村肯定是那纽扣电池你看的是农村可能是打卡了出口南昌您稍等能承诺书,每次那么差那么你你的成绩那现在呢但是我鹑蛋才能到常年开间房间饿哦去我家附近as</string>
</resources>

package com.example.guodongshitu;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        LinearLayout ll=findViewById(R.id.ll);
        LinearLayout ll2=new LinearLayout(MainActivity.this);
        ll2.setOrientation(LinearLayout.VERTICAL);
        ScrollView scrollView=new ScrollView(MainActivity.this);
        ll.addView(scrollView);
        scrollView.addView(ll2);
        ImageView imageView=new ImageView(MainActivity.this);
        imageView.setImageResource(R.drawable.cidian);
        ll2.addView(imageView);
        TextView textView=new TextView(MainActivity.this);
        textView.setText(R.string.cidian);
        ll2.addView(textView);


    }
}

<?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:id="@+id/ll"
    android:orientation="vertical"
    tools:context=".MainActivity">


</LinearLayout>
<resources>
    <string name="app_name">目录滚动视图</string>
    <string name="cidian">java wed坚持检查单身快乐内存卡李女士偶尔吧后阿尔合法化的说法1仓库是顿涅茨克六十年代零库存哪里呢自此嗲承诺的时刻才能大三课程
    踩点上课每次看得出,校门口代码时付了尾款挤破分完IE服务而of后二位好发动机时间内错在哪吃没耐心MV女的子女了南方科技按实际高培培
    大姐夫的时间发文件破费我平均分is大年除之旅VN的可爱浪费及外汇琼海凤凰上课1</string>
</resources>

package com.example.expressionstore;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.TabHost;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TabHost tabHost=findViewById(android.R.id.tabhost);
        tabHost.setup();
        LayoutInflater inflater=LayoutInflater.from(this);
        inflater.inflate(R.layout.tab1,tabHost.getTabContentView());
        inflater.inflate(R.layout.tab2,tabHost.getTabContentView());
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("精选图片").setContent(R.id.left));
        tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("精选图片").setContent(R.id.right));


    }
}

<?xml version="1.0" encoding="utf-8"?>
<TabHost 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:id="@android:id/tabhost"
    tools:context=".MainActivity">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        > </TabWidget>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >

        </FrameLayout>




</LinearLayout>

</TabHost>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:id="@+id/left"
    android:orientation="vertical"
    android:layout_height="match_parent">
<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/a"

    ></ImageView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:id="@+id/right"
    android:orientation="vertical"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/b"

        ></ImageView>

</LinearLayout>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值