• toolbox


    View Code 
    import android.app.Activity;
    import android.os.Bundle;
    import android.webkit.WebView;
    import android.widget.LinearLayout;
    import android.widget.TextView;

    public class testXML extends Activity {
        TitleBar mTitleBar;
        WebView mWebview;
        LinearLayout root;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            root = (LinearLayout)findViewById(R.id.root);
           //mWebview = (WebView)findViewById(R.layout.main);
            
            mTitleBar = new TitleBar(this);
            
            root.addView(mTitleBar);
            
            /*TextView tv = new TextView(this);
            
            tv.setBackgroundColor(0xffff0000);
            
            root.addView(tv);
    */
            
          
        }

    import android.content.Context;
    import android.view.LayoutInflater;
    import android.widget.LinearLayout;

    public class TitleBar extends LinearLayout{
        testXML mBrowserActivity;

        public TitleBar(testXML context) {
            super(context);
            // TODO Auto-generated constructor stub
            
            LayoutInflater factory = LayoutInflater.from(context);
            factory.inflate(R.layout.title_bar, this);
            mBrowserActivity = context;
        }

    }

    main.xml

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

    <WebView android:id="@+id/WebView01" 
    android:layout_width
    ="wrap_content" 
    android:layout_height
    ="wrap_content">
    </WebView>
    </LinearLayout>

    title_bar.xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width
    ="match_parent"
        android:layout_height
    ="wrap_content"
        android:orientation
    ="vertical"
        android:paddingLeft
    ="8dip"
        android:paddingRight
    ="12dip"
        android:paddingTop
    ="2dip"
        android:paddingBottom
    ="1dip"
        android:background
    ="@drawable/search_plate_browser" 
        
    >

        <ProgressBar android:id="@+id/progress_horizontal"
            style
    ="?android:attr/progressBarStyleHorizontal"
            android:layout_width
    ="match_parent"
            android:layout_height
    ="5dip"
            android:layout_marginLeft
    ="2dip"
            android:max
    ="100"
            
    />

        <LinearLayout
            
    android:layout_width="match_parent"
            android:layout_height
    ="wrap_content"
            android:orientation
    ="horizontal"
            
    >

            <LinearLayout android:id="@+id/title_bg"
                android:background
    ="@drawable/title_text"
                android:layout_width
    ="0dip"
                android:layout_weight
    ="1.0"
                android:layout_height
    ="wrap_content"
                android:layout_marginBottom
    ="4dip"
                android:gravity
    ="center_vertical"
                android:orientation
    ="horizontal"
                
    >
                    <ImageView android:id="@+id/favicon"
                        android:layout_width
    ="20dip"
                        android:layout_height
    ="20dip"
                        android:layout_marginLeft
    ="3dip"
                        android:src
    ="@drawable/ico1"
                        
    />
                    <ImageView android:id="@+id/lock"
                        android:layout_width
    ="wrap_content"
                        android:layout_height
    ="wrap_content"
                        android:layout_marginLeft
    ="6dip"
                        android:visibility
    ="gone"
                        android:src
    ="@drawable/ico1"
                        
    />
                    <TextView
                        
    android:id="@+id/title"
                        android:layout_height
    ="wrap_content"
                        android:layout_width
    ="0dip"
                        android:layout_weight
    ="1.0"
                        android:layout_marginLeft
    ="3dip"
                        android:textAppearance
    ="?android:attr/textAppearanceMedium"
                        android:textColor
    ="@color/black"
                        android:gravity
    ="center_vertical"
                        android:singleLine
    ="true"
                        android:ellipsize
    ="end"
                        android:background 
    = "@drawable/ico1"
                    
    />
            </LinearLayout>
            
           
            <ImageView android:id="@+id/stop"
                android:background
    ="@drawable/stop_background"
                android:layout_width
    ="wrap_content"
                android:layout_height
    ="match_parent"
                android:layout_marginBottom
    ="4dip"
                android:src
    ="@drawable/ic_btn_stop_v2"
                android:visibility
    ="gone"
            
    />
            <ImageView
                
    android:id="@+id/rt_btn"
                android:layout_width
    ="wrap_content"
                android:layout_height
    ="match_parent"
                android:layout_marginLeft
    ="-2dip"
                android:layout_marginTop
    ="-6.5dip"
                android:layout_marginBottom
    ="-2dip"
                android:layout_marginRight
    ="-5dip"
                android:scaleType
    ="center"
                android:background
    ="@drawable/btn_bookmark"
                android:src
    ="@drawable/ic_btn_bookmarks"
                android:clickable 
    = "true"
            
    />

        </LinearLayout>
    </LinearLayout>

    title_text.xml

     <selector xmlns:android="http://schemas.android.com/apk/res/android">

        <item android:state_pressed="true"
                android:drawable="@*android:drawable/textfield_search_empty_pressed" />
        <item android:state_pressed="false"
                android:drawable="@*android:drawable/textfield_search_empty_default" />
    </selector>

    stop_background.xml

     <selector xmlns:android="http://schemas.android.com/apk/res/android">


        <item android:state_pressed="true"
            android:drawable="@*android:drawable/btn_search_dialog_pressed" />
        <item android:state_pressed="false"
             android:drawable="@*android:drawable/btn_search_dialog_default" />
    </selector>

     btn_bookmark.xml

     <selector xmlns:android="http://schemas.android.com/apk/res/android">

        <item android:state_pressed="true"
            android:drawable="@*android:drawable/btn_search_dialog_voice_pressed" />
        <item android:state_pressed="false"
            android:drawable="@*android:drawable/btn_search_dialog_voice_default" />
    </selector>
  • 相关阅读:
    Prime Land(poj 1365)
    备用交换机(cogs 8)
    救命(洛谷 U4525)
    消息传递(cogs 1001)
    SQLite 使用主键,ROWID 及自增列
    SqlHelper 类
    一个继承的 DataGridView
    给JAVA的eclipse IDE 在线安装 SVN插件 / 给 eclipse 添加打开所在的文件夹功能
    实时更新DataGridView 合计值
    导出为文本格式
  • 原文地址:https://www.cnblogs.com/fangxiang/p/2372812.html
Copyright © 2020-2023  润新知