【Java转Android】60

慈云数据 1年前 (2024-05-14) 技术支持 46 0

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).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

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);

}

}

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:id=“@+id/appBar”

android:layout_width=“match_parent”

android:layout_height=“250dp”

android:fitsSystemWindows=“true”>

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

android:id=“@+id/toolbar”

android:layout_width=“match_parent”

android:layout_height=“?attr/actionBarSize”

app:layout_collapseMode=“pin” />

android:layout_width=“match_parent”

android:layout_height=“match_parent”

app:layout_behavior=“@string/appbar_scrolling_view_behavior”>

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_marginBottom=“15dp”

android:layout_marginLeft=“15dp”

android:layout_marginRight=“15dp”

android:layout_marginTop=“35dp”

app:cardCornerRadius=“4dp”>

总结

这个月马上就又要过去了,还在找工作的小伙伴要做好准备了,小编整理了大厂java程序员面试涉及到的绝大部分面试题及答案,希望能帮助到大家

在这里插入图片描述

在这里插入图片描述

widget.CardView>

总结

这个月马上就又要过去了,还在找工作的小伙伴要做好准备了,小编整理了大厂java程序员面试涉及到的绝大部分面试题及答案,希望能帮助到大家

[外链图片转存中…(img-E8HAJxjz-1714156067798)]

[外链图片转存中…(img-iTYWgeq6-1714156067799)]

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码收录

微信扫一扫加客服

微信扫一扫加客服

简体中文English