[英]I cannot move CircularImageView in toolbar
I've been struggling for days trying to move the CircularImageView to the right of the toolbar without success.我一直在努力将 CircularImageView 移动到工具栏的右侧,但没有成功。
I would like to have it to the right and more centered (ie without touching toolbar edges), but I cannot do it.我想把它放在右边,更居中(即不接触工具栏边缘),但我做不到。 Just for info, I tried to use both mikhaellopez and hdodenhof libraries without success.
仅供参考,我尝试同时使用 mikhaellopez 和 hdodenhof 库,但没有成功。
Here what I tried (with a placeholder image in the CircularImageView):这是我尝试过的(在 CircularImageView 中使用占位符图像):
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/page_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true"
android:background="@color/primary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mikhaellopez.circularimageview.CircularImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/profile_pic"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:src="@drawable/ic_seed_48dp"
app:civ_border_color="#FFFFFF"
app:civ_border_width="3dp" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
public class HomepageActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.homepage_activity);
pageToolbar = (Toolbar) findViewById(R.id.page_toolbar);
setSupportActionBar(pageToolbar);
...
}
Another question: is it possible to have CircularImageView with a plain background (eg white)?另一个问题:是否可以使用纯背景(例如白色)的 CircularImageView? In fact it is not shown unless I put something within it and I had to put a placeholder image.
事实上,它不会显示,除非我在里面放了一些东西并且我不得不放一个占位符图像。
Thanks in advance!提前致谢!
Yes it is possible to use only a plain background, don't about the library you're using but with hdodenof's you can try this:是的,可以只使用简单的背景,不要使用您正在使用的库,但是使用 hdodenof 可以尝试以下操作:
app:civ_fill_color="@android:color/white"
Also try adding this to your CircularImageView
也尝试将此添加到您的
CircularImageView
android:layout_alignParentRight="true"
The android:layout_alignParentEnd="true"
is as a backup support for RTL layouts, used while creating apps which render layout from RTL instead of LTR. android:layout_alignParentEnd="true"
是作为对 RTL 布局的备份支持,在创建从 RTL 而不是 LTR 渲染布局的应用程序时使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.