仿购物界面布局

package xieshuaikang.com.www.zhoukao1_moni_20171230.View.Activity;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import xieshuaikang.com.www.zhoukao1_moni_20171230.R;
import xieshuaikang.com.www.zhoukao1_moni_20171230.View.Fragment.ShouYe_Fragment;

public class MainActivity extends AppCompatActivity {

    private FrameLayout frameLayout;
    private RadioButton rb1;
    private RadioButton rb2;
    private RadioButton rb3;
    private RadioButton rb4;
    private RadioGroup rg;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if (Build.VERSION.SDK_INT >= 21) {
            View decorView = getWindow().getDecorView();
            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            decorView.setSystemUiVisibility(option);
            getWindow().setStatusBarColor(Color.TRANSPARENT);
        }
        ActionBar actionBar = getSupportActionBar();
        actionBar.hide();
        initView();
        getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,new ShouYe_Fragment()).commit();
    }

    private void initView() {
        frameLayout = (FrameLayout) findViewById(R.id.frameLayout);
        rb1 = (RadioButton) findViewById(R.id.rb1);
        rb2 = (RadioButton) findViewById(R.id.rb2);
        rb3 = (RadioButton) findViewById(R.id.rb3);
        rb4 = (RadioButton) findViewById(R.id.rb4);
        rg = (RadioGroup) findViewById(R.id.rg);
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                switch (i){
                    case R.id.rb1:
                        getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,new ShouYe_Fragment()).commit();
                        break;
                    case R.id.rb2:
                       break;
                    case R.id.rb3:
                        break;
                    case R.id.rb4:
                        break;
                }
            }
        });
    }
}
<?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="xieshuaikang.com.www.zhoukao1_moni_20171230.View.Activity.MainActivity">
<FrameLayout
android:id="@+id/frameLayout"
android:layout_weight="9"
android:layout_width="match_parent"
android:layout_height="0dp"></FrameLayout>
<RadioGroup
android:orientation="horizontal"
android:id="@+id/rg"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp">
<RadioButton
android:checked="true"
android:background="@drawable/selector1"
android:id="@+id/rb1"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="match_parent" />
<RadioButton
android:background="@drawable/selector2"
android:id="@+id/rb2"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="match_parent" />
<RadioButton
android:background="@drawable/selector4"
android:id="@+id/rb3"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="match_parent" />

<RadioButton
android:background="@drawable/selector5"
android:id="@+id/rb4"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="match_parent" />
</RadioGroup>
</LinearLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值