由网友(薯片小姐姐)分享简介:就像谷歌加了上面的截图,我要显示在操作栏中的圆形头像图片。我该怎么办?解决方案 创建圆形ImageView的。使用圆形的ImageView创建动作条自定义视图充气视图,并显示自定义视图的操作栏。< RelativeLayout的的xmlns:机器人=http://schemas.android.c...
就像谷歌加了上面的截图,我要显示在操作栏中的圆形头像图片。我该怎么办?
解决方案 创建圆形ImageView的。 使用圆形的ImageView创建动作条自定义视图 充气视图,并显示自定义视图的操作栏。< RelativeLayout的的xmlns:机器人=http://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?
解决方案 Create circular imageview. Create custom view for actionbar using the circular imageview 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);
相关推荐
最新文章