写点什么

【Java 转 Android】60,androidx86 输入法

用户头像
Android架构
关注
发布于: 11 小时前

package aystudio.nopi.materialdesign;


import android.content.Intent;


import android.graphics.Color;


import android.support.design.widget.CollapsingToolbarLayout;


import android.support.v7.app.ActionBar;


import android.support.v7.app.AppCompatActivity;


import android.os.Bundle;


import android.support.v7.widget.Toolbar;


import android.view.MenuItem;


import android.widget.ImageView;


import android.widget.TextView;


import com.bumptech.glide.Glide;


public class FruitActivity extends AppCompatActivity {


public static final String FRUIT_NAME = "fruit_name";


public static final String FRUIT_IMAGE_ID = "fruit_image_id";


@Override


protected void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);


setContentView(R.layout.activity_fruit);


Intent intent = getIntent();


String fruitName = intent.getStringExtra(FRUIT_NAME);


int fruitImageId = intent.getIntExtra(FRUIT_IMAGE_ID, 0);


Toolbar toolbar = findViewById(R.id.toolbar);


CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapsing_toolbar);


ImageView fruitImageView = findViewById(R.id.fruit_image_view);


TextView fruitContentText = findViewById(R.id.fruit_content_text);


setSupportActionBar(toolbar);


ActionBar actionBar = getSupportActionBar();


if (actionBar != null) {


actionBar.setDisplayHomeAsUpEnabled(true);


}


collapsingToolbar.setTitle(fruitName);


Glide.with(this)


《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》
浏览器打开:qq.cn.hn/FTe 免费领取
复制代码


.load(fruitImageId).into(fruitImageView);


String fruitContent = generateFruitContent(fruitName);


fruitContentText.setText(fruitContent);


}


private String generateFruitContent(String fruitName) {


StringBuilder fruitContent = new StringBuilder();


for (int i = 0; i < 500; i++) {


fruitContent.append(fruitName);


}


return fruitContent.toString();


}


@Override


public boolean onOptionsItemSelected(MenuItem item) {


switch (item.getItemId()) {


case android.R.id.home:


finish();


return true;


}


return super.onOptionsItemSelected(item);


}


}


<?xml version="1.0" encoding="utf-8"?>


<android.support.design.widget.CoordinatorLayout


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


xmlns:app="http://schemas.android.com/apk/res-auto"


android:layout_width="match_parent"


android:layout_height="match_parent"


android:fitsSystemWindows="true">


<android.support.design.widget.AppBarLayout


android:id="@+id/appBar"


android:layout_width="match_parent"


android:layout_height="250dp"


android:fitsSystemWindows="true">


<android.support.design.widget.CollapsingToolbarLayout


android:id="@+id/collapsing_toolbar"


android:layout_width="match_parent"


android:layout_height="match_parent"


android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"


android:fitsSystemWindows="true"


app:contentScrim="?attr/colorPrimary"


app:layout_scrollFlags="scroll|exitUntilCollapsed">


<ImageView


android:id="@+id/fruit_image_view"


android:layout_width="match_parent"


android:layout_height="match_parent"


android:scaleType="centerCrop"


android:fitsSystemWindows="true"


app:layout_collapseMode="parallax" />


<android.support.v7.widget.Toolbar

用户头像

Android架构

关注

还未添加个人签名 2021.10.31 加入

还未添加个人简介

评论

发布
暂无评论
【Java转Android】60,androidx86输入法