作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Collapsing Toolbar
中有一个 ImageView
和 TextView
。图像将从服务器动态加载。问题是当我为 TextView
(白色或黑色)设置颜色时,它以某种方式与图像的颜色相矛盾。由于我是初学者,我不知道如何解决它。谁能帮我解决这个问题?
公告 Activity
public class AnnouncementDetailsActivity extends AppCompatActivity {
private TextView mTitle;
private TextView mDescription;
private ImageView image;
private ProgressDialog progressDialog;
private String mAnnouncementTitle;
private String mAnnouncementDescription;
private String mAnnounceImage;
public GetAnnouncementTask mGetAnnouncement = null;
private String DateString = DateFormat.getDateInstance(DateFormat.SHORT).format(Calendar.getInstance().getTime());
private static final String TAG = "AnnouncementDetailsActivity";
public static final String TAG_ANNOUNCEMENT_LIST_FRAGMENT = "announcement_list_fragment";
private CollapsingToolbarLayout collapsingToolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.rgb(38, 55, 98));
}
setContentView(R.layout.activity_announcement_details);
mTitle = (TextView) findViewById(R.id.announcement_title);
mDescription = (TextView) findViewById(R.id.description);
image = (ImageView) findViewById(R.id.announcement_image);
collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.detail_collapse_toolbar);
collapsingToolbar.setTitle(mAnnouncementTitle);
//
// collapsingToolbar.setCollapsedTitleTextColor(getResources().getColor(android.R.color.black));
collapsingToolbar.setExpandedTitleColor(getResources().getColor(android.R.color.black));
setSupportActionBar((Toolbar) findViewById(R.id.detail_announcement_toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
Intent intent = getIntent();
if (null != intent) {
mAnnouncementTitle = intent.getStringExtra("announceTitle");
mAnnouncementDescription = intent.getStringExtra("announceDescription");
mAnnounceImage = intent.getStringExtra("announceImage");
mTitle.setText(mAnnouncementTitle);
mDescription.setText(mAnnouncementDescription);
new GetAnnouncementTask(image)
.execute(mAnnounceImage);
}
}
public class GetAnnouncementTask extends AsyncTask<String, Void, Bitmap> {
ImageView image;
public GetAnnouncementTask(ImageView bmImage) {
this.image = bmImage;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
protected Bitmap doInBackground(String... urls) {
String url = urls[0];
Bitmap mIcon = null;
try {
InputStream in = new java.net.URL(url.replaceAll(" ", "%20")).openStream();
mIcon = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
}
return mIcon;
}
protected void onPostExecute(Bitmap result) {
image.setImageBitmap(result);
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
public boolean onOptionsItemSelected(MenuItem item) {
onBackPressed();
return true;
}
}
最佳答案
关于android - 为折叠工具栏中的 TextView 和 ImageView 设置对比色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36909658/
在 paletta 中,我可以看到对比。如何选择对比色? 作品: scss mat-color($button-primary); 不工作 scss mat-color($button-primary
我是一名优秀的程序员,十分优秀!