如何显示一个圆形的标志在行动酒吧Android的? [英] How to show a circular logo in action bar in Android?

查看:161
本文介绍了如何显示一个圆形的标志在行动酒吧Android的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像谷歌加了上面的截图,我要显示在操作栏中的圆形头像图片。我该怎么办?

解决方案
  1. 创建圆形ImageView的。
  2. 使用圆形的ImageView创建动作条自定义视图
  3. 充气视图,并显示自定义视图的操作栏。

< RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android 机器人:layout_width =match_parent 机器人:layout_height =50dp 机器人:背景=@可绘制/ black_pattern> <的TextView  机器人:ID =@ + ID / title_text  机器人:layout_width =WRAP_CONTENT  机器人:layout_height =WRAP_CONTENT  机器人:layout_centerInParent =真  机器人:textAllCaps =真  机器人:textAppearance =机器人:ATTR / textAppearanceLarge  机器人:文字颜色=#FFF  机器人:TEXTSTYLE =黑体/> < com.example.CircularImageView  机器人:ID =@ + ID / circularimageView1  机器人:layout_width =35dp  机器人:layout_height =35dp  机器人:layout_alignParentLeft =真  机器人:layout_centerVertical =真  机器人:layout_marginLeft =8DP/> < / RelativeLayout的>

Activity.java

 动作条mActionBar = getActionBar();
mActionBar.setDisplayShowHomeEnabled(假);
mActionBar.setDisplayShowTitleEnabled(假);
LayoutInflater mInflater = LayoutInflater.from(本);

查看mCustomView = mInflater.inflate(R.layout.actionbar,NULL);

mActionBar.setCustomView(mCustomView);
mActionBar.setDisplayShowCustomEnabled(真正的);
 

Just like the screenshot of Google Plus above, I want to show a circular avatar image in the action bar. What should I do?

解决方案

  1. Create circular imageview.
  2. Create custom view for actionbar using the circular imageview
  3. Inflate the view and display custom view as action bar.

<RelativeLayout         xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/black_pattern" >

<TextView
 android:id="@+id/title_text"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_centerInParent="true"
 android:textAllCaps="true"
 android:textAppearance="?android:attr/textAppearanceLarge"
 android:textColor="#fff"
 android:textStyle="bold" />

<com.example.CircularImageView
 android:id="@+id/circularimageView1"
 android:layout_width="35dp"
 android:layout_height="35dp"
 android:layout_alignParentLeft="true"
 android:layout_centerVertical="true"
 android:layout_marginLeft="8dp"/>

</RelativeLayout> 

Activity.java

ActionBar mActionBar = getActionBar();
mActionBar.setDisplayShowHomeEnabled(false);
mActionBar.setDisplayShowTitleEnabled(false);
LayoutInflater mInflater = LayoutInflater.from(this);

View mCustomView = mInflater.inflate(R.layout.actionbar, null);

mActionBar.setCustomView(mCustomView);
mActionBar.setDisplayShowCustomEnabled(true);

这篇关于如何显示一个圆形的标志在行动酒吧Android的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆