情景模式的界面设计



情景模式的界面设计

一、

1、activity_main.xml

<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:background="@drawable/bg"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >

        <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" >

                <include layout="@layout/ringofile_normal" />

                <include layout="@layout/ringprofile_timer" />

                <include layout="@layout/ringprofile_selfdefination" />
            </FrameLayout>
        </LinearLayout>
    </TabHost>

</RelativeLayout>

2、ringofile_normal.xml

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

    <RadioGroup
        android:id="@+id/ringSet"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="40dp"
        android:layout_marginTop="52dp" >

        <RadioButton
            android:id="@+id/ringAndVibrate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="铃声和震动"
            android:textSize="20sp" />

        <RadioButton
            android:id="@+id/ring"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="铃声"
            android:textSize="20sp" />

        <RadioButton
            android:id="@+id/vibrate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="震动"
            android:textSize="20sp" />

        <RadioButton
            android:id="@+id/silent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="静音"
            android:textSize="20sp" />
    </RadioGroup>

</RelativeLayout>

3、ringprofile_selfdefination.xml

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

    <TextView
        android:id="@+id/tv_voice"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tv_prompt"
        android:layout_below="@+id/tv_prompt"
        android:layout_marginTop="23dp"
        android:text="声音音量:"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <ProgressBar
        android:id="@+id/voiceBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:max="100"
        android:progress="70"
        android:layout_alignBottom="@+id/tv_voice"
        android:layout_marginLeft="15dp"
        android:layout_toRightOf="@+id/tv_voice" />

    <ImageButton
        android:id="@+id/down"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tv_voice"
        android:layout_below="@+id/tv_voice"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="21dp"
        android:src="@drawable/down" />

    <ImageButton
        android:id="@+id/up"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/down"
        android:layout_toRightOf="@+id/tv_voice"
        android:src="@drawable/up" />

    <ImageButton
        android:id="@+id/vibrate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/silent"
        android:layout_toRightOf="@+id/tv_prompt"
        android:src="@drawable/vibrate" />

    <ImageButton
        android:id="@+id/normal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/down"
        android:layout_marginRight="41dp"
        android:layout_marginTop="19dp"
        android:layout_toLeftOf="@+id/silent"
        android:src="@drawable/normal" />

    <ImageButton
        android:id="@+id/silent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/normal"
        android:layout_centerHorizontal="true"
        android:src="@drawable/mute" />

    <TextView
        android:id="@+id/tv_prompt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="37dp"
        android:drawableRight="@drawable/normal"
        android:text="情景模式:"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>

3、ringprofile_selfdefination.xml

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

    <TextView
        android:id="@+id/tv_voice"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tv_prompt"
        android:layout_below="@+id/tv_prompt"
        android:layout_marginTop="23dp"
        android:text="声音音量:"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <ProgressBar
        android:id="@+id/voiceBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:max="100"
        android:progress="70"
        android:layout_alignBottom="@+id/tv_voice"
        android:layout_marginLeft="15dp"
        android:layout_toRightOf="@+id/tv_voice" />

    <ImageButton
        android:id="@+id/down"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tv_voice"
        android:layout_below="@+id/tv_voice"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="21dp"
        android:src="@drawable/down" />

    <ImageButton
        android:id="@+id/up"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/down"
        android:layout_toRightOf="@+id/tv_voice"
        android:src="@drawable/up" />

    <ImageButton
        android:id="@+id/vibrate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/silent"
        android:layout_toRightOf="@+id/tv_prompt"
        android:src="@drawable/vibrate" />

    <ImageButton
        android:id="@+id/normal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/down"
        android:layout_marginRight="41dp"
        android:layout_marginTop="19dp"
        android:layout_toLeftOf="@+id/silent"
        android:src="@drawable/normal" />

    <ImageButton
        android:id="@+id/silent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/normal"
        android:layout_centerHorizontal="true"
        android:src="@drawable/mute" />

    <TextView
        android:id="@+id/tv_prompt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="37dp"
        android:drawableRight="@drawable/normal"
        android:text="情景模式:"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>

4、ringprofile_timer.xml

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

    <TextView
        android:id="@+id/tv_timeSetPrompt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="37dp"
        android:text="设置时间"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <RadioGroup
        android:id="@+id/ringSet"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/timePicker1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="31dp" >

        <RadioButton
            android:id="@+id/ringAndVibrate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="铃声和震动"
            android:textSize="20sp" />

        <RadioButton
            android:id="@+id/ring"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="铃声"
            android:textSize="20sp" />

        <RadioButton
            android:id="@+id/vibrate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="震动"
            android:textSize="20sp" />

        <RadioButton
            android:id="@+id/silent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="静音"
            android:textSize="20sp" />
    </RadioGroup>

    <TimePicker
        android:id="@+id/timePicker1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/tv_timeSetPrompt"
        android:layout_below="@+id/tv_timeSetPrompt" />

"

</RelativeLayout>

5、MainActivity.java

package com.example.ui7;

import android.os.Bundle;
import android.app.Activity;
import android.app.TabActivity;
import android.view.Menu;
import android.widget.TabHost;

public class MainActivity extends TabActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		TabHost tabHost = getTabHost();
		TabHost.TabSpec normalTab = tabHost.newTabSpec("tab1");
		normalTab.setIndicator("普通情景模式",
				getResources().getDrawable(R.drawable.normal)).setContent(
				R.id.ringofile_normal);
		tabHost.addTab(normalTab);
		TabHost.TabSpec timerTab = tabHost.newTabSpec("tab2");
		timerTab.setIndicator("定时情景模式",
				getResources().getDrawable(R.drawable.time)).setContent(
				R.id.ringprofile_timer);
		tabHost.addTab(timerTab);
		TabHost.TabSpec selfDefinationTab = tabHost.newTabSpec("tab3");
		selfDefinationTab.setIndicator("自定义情景模式",
				getResources().getDrawable(R.drawable.selfdefination)).setContent(
				R.id.ringprofile_selfdefination);
		tabHost.addTab(selfDefinationTab);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}

二、运行效果图

 




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值