day06 RelativeLayout LinearLayout FrameLayout

  1. 相对布局管理器使用
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="16dp"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="16dp"
    android:background="@mipmap/kucaiba"
    tools:context=".MainActivity">
    <!--    android:gravity="center"-->
    <!--    android:ignoreGravity="@id/user"-->
    <!--tools:context 指定 activity 不会被打包到 apk-->
    <!-- android:gravity 组件的摆放位置 android:ignoreGravity  不受前面控制  -->
    <!-- RelativeLayout.layoutParams   -->
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="发现有新版本,您想现在安装吗?"
        android:id="@+id/text1"
        />

<!--    <TextView-->
<!--        android:layout_width="wrap_content"-->
<!--        android:layout_height="wrap_content"-->
<!--        android:layout_below="@id/text1"-->
<!--        android:text="mm"-->
<!--        android:id="@+id/mm"-->
<!--        />-->
<!--           android:layout_alignRight="@id/text1" -->
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@id/text1"
        android:text="以后再说"
        android:id="@+id/btnCancel"
        />
<!--            android:layout_toLeftOf="@id/btnCancel" -->
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/text1"
        android:text="现在更新"
        android:id="@+id/btnUpdate"
        />
</RelativeLayout>

  1. LinearLayout
  2. FrameLayout 主要是用于 层级叠加
    两个重要属性 android:foreground android:foregroundGravity right|bottom
  3. GridLayout
    android:columnCount="6"
          android:layout_columnSpan="4"
        android:layout_column="1"
        android:layout_row="0"

##嵌套布局管理器
嵌套规则
5. 只能有一个 根布局管理器
6.根布局管理必须包含xmlns属性
7.不能嵌套太深 否则影响性能

#单选框
RadioGroup getChildCount()
RadioButton idChecked()
#复选框
CheckBox

#日期选择器
DatePicker Calendar

#时间选择器
TimePicker setIs24HourView(true)

#计时器
Chronometer format
setBase
setOnChronometerTickListener
start
stop

#倒计时

        final TextView textView = new TextView(MainActivity.this);
        textView.setText("60");
        textView.setTextSize(45);
        textView.setTextColor(getResources().getColor(R.color.colorPrimary));
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        textView.setLayoutParams(params);
        LinearLayout linearLayout = (LinearLayout)findViewById(R.id.myLinearLayout);
        linearLayout.addView(textView);
        textView.setGravity(Gravity.RIGHT);
                new CountDownTimer(10000, 1000) {
            public void onTick(long millisUntilFinished) {
                Log.i("info", "seconds remaining: " + millisUntilFinished / 1000);
                //ch.setText("" +( millisUntilFinished / 1000) );
                textView.setText("" +( millisUntilFinished / 1000 - 1));
            }

            public void onFinish() {
                Log.i("info", "done!");
            }
        }.start();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值