欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

怎么在Android中使用Kotlin實(shí)現(xiàn)一個(gè)登錄界面-創(chuàng)新互聯(lián)

怎么在Android中使用Kotlin實(shí)現(xiàn)一個(gè)登錄界面?很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。

創(chuàng)新互聯(lián)公司主營(yíng)東鄉(xiāng)網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,重慶App定制開(kāi)發(fā),東鄉(xiāng)h5微信小程序開(kāi)發(fā)搭建,東鄉(xiāng)網(wǎng)站營(yíng)銷(xiāo)推廣歡迎東鄉(xiāng)等地區(qū)企業(yè)咨詢

登錄界面代碼如下:

class LoginActivity : AppCompatActivity(), View.OnClickListener {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    //setContentView(R.layout.activity_login)
    LoginUi().setContentView(this@LoginActivity)
  }
  lateinit var et_account: EditText
  lateinit var et_password: EditText
  inner class LoginUi : AnkoComponent<LoginActivity> {
    override fun createView(ui: AnkoContext<LoginActivity>) = with(ui) {
      verticalLayout {
        backgroundColor = context.resources.getColor(android.R.color.white)
        gravity = Gravity.CENTER_HORIZONTAL
        imageView(R.drawable.touxiang).lparams {
          width = dip(100)
          height = dip(100)
          topMargin = dip(64)
        }
        linearLayout {
          gravity = Gravity.CENTER_VERTICAL
          orientation = HORIZONTAL
          backgroundResource = R.drawable.bg_frame_corner
          imageView {
            image = resources.getDrawable(R.mipmap.ic_username)
          }.lparams(width = wrapContent, height = wrapContent) {
            leftMargin = dip(12)
            rightMargin = dip(15)
          }
          et_account = editText {
            hint = "登錄賬戶"
            hintTextColor = Color.parseColor("#666666")
            textSize = 14f
            background = null
          }.lparams {
            topMargin = dip(5)
          }
        }.lparams(width = dip(300), height = dip(40)) {
          topMargin = dip(30)
        }
        linearLayout {
          gravity = Gravity.CENTER_VERTICAL
          orientation = HORIZONTAL
          backgroundResource = R.drawable.bg_frame_corner
          imageView {
            image = resources.getDrawable(R.mipmap.ic_password)
          }.lparams(width = wrapContent, height = wrapContent) {
            leftMargin = dip(12)
            rightMargin = dip(15)
          }
          et_password = editText {
            hint = "賬戶密碼"
            hintTextColor = Color.parseColor("#666666")
            textSize = 14f
            background = null
          }.lparams {
            topMargin = dip(5)
          }
        }.lparams {
          width = dip(300)
          height = dip(40)
          topMargin = dip(10)
        }
        button("登錄") {
          gravity = Gravity.CENTER
          background = resources.getDrawable(R.drawable.bg_login_btn)
          textColor = Color.parseColor("#ffffff")
          textSize = 18f
          onClick {
            if (et_account.text.toString().isNotEmpty() && et_password.text.toString().isNotEmpty())
              startActivity<MainActivity>() else toast("請(qǐng)輸入賬戶或者密碼")
          }
        }.lparams(width = dip(300), height = dip(44)) {
          topMargin = dip(18)
        }
        linearLayout {
          orientation = HORIZONTAL
          gravity = Gravity.CENTER_VERTICAL
          checkBox("記住密碼") {
            textColor = Color.parseColor("#666666")
            textSize = 16f
            leftPadding = dip(5)
          }
          textView("新用戶注冊(cè)") {
            textColor = Color.parseColor("#1783e3")
            gravity = Gravity.RIGHT
            textSize = 16f
          }.lparams(width = matchParent)
        }.lparams(width = dip(300)) {
          topMargin = dip(18)
        }
        textView("Copyright &copy; Henry") {
          textSize = 14f
          gravity = Gravity.CENTER or Gravity.BOTTOM
        }.lparams {
          bottomMargin = dip(35)
          weight = 1f
        }
      }
    }
  }
  override fun onClick(v: View) {
    when (v.id) {
    }
  }
}

  實(shí)現(xiàn)出來(lái)的效果和我們?cè)O(shè)置布局文件所實(shí)現(xiàn)的效果一樣,但是相比使用布局文件來(lái)說(shuō),使用Kotlin將會(huì)更加的簡(jiǎn)潔明了,省去了定義變量和查找布局文件的操作,大大解放了我們程序員;

  下面的代碼所示是筆者使用布局文件實(shí)現(xiàn)的布局效果,和上面的效果一樣,但是會(huì)復(fù)雜很多,大家可以自己自己體會(huì)一下;

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_gravity="center_horizontal"
  android:background="#ffffff"
  android:orientation="vertical"
  android:padding="40dp">
  <de.hdodenhof.circleimageview.CircleImageView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/profile_image"
    android:layout_width="96dp"
    android:layout_height="96dp"
    android:layout_gravity="center_horizontal"
    android:src="@drawable/touxiang"
    app:civ_border_color="#FF000000"
    app:civ_border_width="2dp" />
  <LinearLayout
    android:id="@+id/lin_count"
    android:layout_width="300dp"
    android:layout_height="40dp"
    android:layout_marginTop="45dp"
    android:background="@drawable/bg_frame_corner"
    android:gravity="center_vertical"
    android:orientation="horizontal">
    <ImageView
      android:layout_width="wrap_content"
      android:layout_height="25dp"
      android:layout_marginLeft="12dp"
      android:layout_marginRight="15dp"
      android:src="@drawable/count" />
    <EditText
      android:id="@+id/loginAccount"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@null"
      android:hint="登錄賬戶"
      android:maxLength="11"
      android:textSize="16sp" />
  </LinearLayout>
  <LinearLayout
    android:id="@+id/lin_password"
    android:layout_width="300dp"
    android:layout_height="40dp"
    android:layout_marginTop="10dp"
    android:background="@drawable/bg_frame_corner"
    android:gravity="center_vertical"
    android:orientation="horizontal">
    <ImageView
      android:layout_width="wrap_content"
      android:layout_height="25dp"
      android:layout_marginLeft="12dp"
      android:layout_marginRight="15dp"
      android:src="@drawable/password"/>
    <EditText
      android:id="@+id/loginPassword"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@null"
      android:hint="賬戶密碼"
      android:password="true"
      android:maxLength="11"
      android:textSize="16sp"/>
  </LinearLayout>
  <Button
    android:id="@+id/login_button"
    android:layout_width="300dp"
    android:layout_height="44dp"
    android:layout_gravity="center"
    android:background="@drawable/bg_login_btn"
    android:layout_marginTop="18dp"
    android:text="登錄"
    android:textColor="#ffffff"
    android:textSize="18sp" />
  <LinearLayout
    android:id="@+id/lin_remember"
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="18dp"
    android:gravity="center_vertical"
    android:orientation="horizontal">
    <CheckBox
      android:id="@+id/rem_pas_check"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="5dp"
      android:text="記住密碼"
      android:textColor="#666666"
      android:textSize="16sp" />
    <TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:gravity="right"
      android:text="新用戶注冊(cè)"
      android:textColor="#1783e3"
      android:textSize="16sp" />
  </LinearLayout>
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="35dp"
    android:layout_weight="1"
    android:gravity="bottom|center"
    android:text="Copyright &copy; Henry"
    android:textSize="14sp" />
</LinearLayout>

看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。

名稱欄目:怎么在Android中使用Kotlin實(shí)現(xiàn)一個(gè)登錄界面-創(chuàng)新互聯(lián)
文章路徑:http://aaarwkj.com/article2/hodoc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、品牌網(wǎng)站制作、服務(wù)器托管、搜索引擎優(yōu)化、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化
欧美黄片完整版在线观看| 日本欧美亚洲一区二区三区| 中文字幕人妻熟女人妻| 日韩一区二区三区91| 亚洲精品永久在线观看| 亚洲国产成人91精品| 老熟女乱色一区二区三区| 欧美亚洲一区二区三区91| 五月婷婷六月丁香伊人妞| 精品人妻一区二区三区在线av | 欧美日本在线区一区二| 国产在线精品91国自产拍| 久草福利视频免费播放| 国产一区黄片视频在线观看| 欧美一区日韩二区国产三区| 首页亚洲一区二区三区| 亚洲av产在线精品亚洲第| 成年人性生活一级视品| 中文字幕亚洲欧美日韩高清 | 亚洲av成人av天堂| 久久人人97超碰人人爱一久久精品 | 欧美黄色影院在线观看| 久久精品夜夜夜夜夜久久| 大香蕉欧美视频伊在线| 97青青草免费在线视频| 色老头视频一区二区三区 | 亚洲精品日韩国产3区| 国产三级三级三级精品8ⅰ区| 日韩精品 视频二区| 三级视频一区二区三区| 欧美 成人一区二区三区| 国产精品大屁股白浆一区二区 | av在线中文字幕剧情| 亚洲国产日韩欧美在线播放| 日韩一二三四区精品电影免费播放| 日韩精品中文字幕影视| 加勒比在线观看欧美一区| 国产午夜在线影院一区二区| 欧美一区日韩二区国产三区| 麻豆视频传媒入口在线播放 | 国产91精品成人在线观看|