{"rsdb":{"rid":"409750","subhead":"","postdate":"0","aid":"283063","fid":"98","uid":"1","topic":"1","content":"
\n

\u4e00\u3001 \u5bf9UI\u754c\u9762\u5c3d\u5fc3\u81ea\u5b9a\u4e49\u7ec4\u4ef6<\/p> \n

\n
package<\/span> com.example.uicustomviews;\n\n?\n\n<\/span>import<\/span> android.app.Activity;\n\n<\/span>import<\/span> android.os.Bundle;\n\n<\/span>import<\/span> android.view.Menu;\n\n<\/span>import<\/span> android.view.MenuItem;\n\n<\/span>import<\/span> android.view.Window;\n\n?\n\n<\/span>public<\/span> class<\/span> MainActivity extends<\/span> Activity {\n\n?\n\n  @Override\n\n  <\/span>protected<\/span> void<\/span> onCreate(Bundle savedInstanceState) {\n\n    <\/span>super<\/span>.onCreate(savedInstanceState);\n\n    requestWindowFeature(Window.FEATURE_NO_TITLE);\n\n    setContentView(R.layout.activity_main);\n\n  }\n\n?\n\n}<\/span><\/pre> \n <\/div> \n 

 <\/p> \n

\n
?\n\n<\/span><?<\/span>xml version="1.0" encoding="utf-8"<\/span>?><\/span>\n\n<<\/span>LinearLayout <\/span>xmlns:android<\/span>="http:\/\/schemas.android.com\/apk\/res\/android"<\/span>\n\n    android:layout_width<\/span>="match_parent"<\/span>\n\n    android:layout_height<\/span>="match_parent"<\/span>\n\n    android:background<\/span>="@drawable\/title_bg"<\/span>\n\n    ><\/span>\n\n    <!--<\/span> \u8fd9\u91cc\u6211\u4eec\u81ea\u5b9a\u4e49\u4e86\u4e00\u4e2a\u80cc\u666f\u56fe\u7247title_bg\uff0c\u5e76\u4e14\u5728res\u6587\u4ef6\u5939\u4e2d\u4fdd\u5b58\u4e86\u8fd9\u5f20\u56fe\u7247 <\/span>--><\/span>\n\n    <!--<\/span> \u4e0b\u9762\u7684margin\u5373\u4ee3\u8868\u5916\u8fb9\u8ddd\uff0c\u7c7b\u4f3c\u4e8e\u4e4b\u524d\u5b66\u8fc7\u7684HTML\/CSS\u4e2d\u7684\u5c5e\u6027\u8bbe\u7f6e <\/span>--><\/span>\n\n    <<\/span>Button\n\n        <\/span>android:id<\/span>="@+id\/title_back"<\/span>\n\n        android:layout_width<\/span>="wrap_content"<\/span>\n\n        android:layout_height<\/span>="wrap_content"<\/span>\n\n        android:layout_gravity<\/span>="center"<\/span>\n\n        android:layout_margin<\/span>="5dip"<\/span>\n\n        android:background<\/span>="@drawable\/title_bg"<\/span>\n\n        android:text<\/span>="Back"<\/span>\n\n        android:textColor<\/span>="#fff"<\/span>\n\n        \/><\/span>\n\n    <<\/span>TextView\n\n        <\/span>android:id<\/span>="@+id\/title_text"<\/span>\n\n        android:layout_width<\/span>="0dip"<\/span>\n\n        android:layout_height<\/span>="wrap_content"<\/span>\n\n        android:layout_gravity<\/span>="center"<\/span>\n\n        android:layout_weight<\/span>="1"<\/span>\n\n        android:gravity<\/span>="center"<\/span>\n\n        android:text<\/span>="Title Text"<\/span>\n\n        android:textColor<\/span>="#fff"<\/span>\n\n        android:textSize<\/span>="24sp"<\/span> \/><\/span>\n\n   \n\n    <<\/span>Button\n\n        <\/span>android:id<\/span>="@+id\/title_edit"<\/span>\n\n        android:layout_width<\/span>="wrap_content"<\/span>\n\n        android:layout_height<\/span>="wrap_content"<\/span>\n\n        android:layout_gravity<\/span>="center"<\/span>\n\n        android:layout_margin<\/span>="5dip"<\/span>\n\n        android:background<\/span>="@drawable\/title_bg"<\/span>\n\n        android:text<\/span>="Edit"<\/span>\n\n        android:textColor<\/span>="#fff"<\/span> \/><\/span>\n\n?\n\n<\/span><\/<\/span>LinearLayout<\/span>><\/span><\/pre> \n <\/div> \n 

 <\/p> \n

?<\/p> \n

\n
<<\/span>LinearLayout <\/span>xmlns:android<\/span>="http:\/\/schemas.android.com\/apk\/res\/android"<\/span>\n\n  android:layout_width<\/span>="match_parent"<\/span>\n\n  android:layout_height<\/span>="match_parent"<\/span> ><\/span>\n\n \n\n    <<\/span>com.example.uicustomviews.TitleLayout\n\n        <\/span>android:layout_width<\/span>="match_parent"<\/span>\n\n        android:layout_height<\/span>="wrap_content"<\/span>><\/span>\n\n       \n\n    <\/<\/span>com.example.uicustomviews.TitleLayout<\/span>><\/span>\n\n?\n\n    <\/span><<\/span>include <\/span>layout<\/span>="@layout\/title"<\/span> \/><\/span>\n\n?\n\n  <\/span><!--<\/span> \u8fd9\u91cc\u4f7f\u7528include\u8bed\u53e5\u6765\u5bfc\u5165\u6211\u4eec\u521a\u624d\u5199\u7684\u6807\u9898xml <\/span>--><\/span>\n\n?\n\n<\/span><\/<\/span>LinearLayout<\/span>><\/span><\/pre> \n <\/div> \n 

 <\/p> \n

?<\/p> \n

\n
package<\/span> com.example.uicustomviews;\n\n<\/span>import<\/span> android.widget.LinearLayout;\n\n<\/span>import<\/span> android.widget.Toast;\n\n<\/span>import<\/span> android.content.Context;\n\n<\/span>import<\/span> android.util.AttributeSet;\n\n<\/span>import<\/span> android.view.LayoutInflater;\n\n<\/span>import<\/span> android.widget.Button;\n\n<\/span>import<\/span> android.widget.Toast;\n\n<\/span>\/\/<\/span>import android.<\/span>\n\n?\n\n?\n\n<\/span>public<\/span> class<\/span> TitleLayout extends<\/span> LinearLayout{\n\n  <\/span>public<\/span> TitleLayout(Context context,AttributeSet attrs) {\n\n    <\/span>super<\/span>(context,attrs);\n\n    LayoutInflater.from(context).inflate(R.layout.title,<\/span>this<\/span>);\n\n    Button titleBack <\/span>= (Button) findViewById(R.id.title_","orderid":"0","title":"Android\u8fde\u8f7d1-\u81ea\u5b9a\u4e49UI\u63a7\u4ef6(\u4e00)","smalltitle":"","mid":"0","fname":"Android","special_id":"0","bak_id":"0","info":"0","hits":"63","pages":"2","comments":"0","posttime":"2020-04-02 09:20:23","list":"1585790423","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"Android<\/A> \u8fde\u8f7d<\/A> \u5b9a\u4e49<\/A> \u63a7\u4ef6<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.17.22.34","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"Android\u8fde\u8f7d1-\u81ea\u5b9a\u4e49UI\u63a7\u4ef6","lastview":"1590222854","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}