2017-10-08 5 views
-1

CircularImageViewをツールバーの右に移動しようと数日間苦労しました。ツールバーのCircularImageViewを移動できません

ツールバーのエッジに触れることなく、右寄りにしたいと思っていますが、できません。 ちょうど情報のために、私は成功なしでmikhaellopezとhdodenhofライブラリの両方を使用しようとしました。

私は(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); 
     ... 
} 

This is the result

別の質問:それは無地の背景とCircularImageViewを持つことが可能である(たとえば、白)?実際には、その中に何かを入れない限り表示されず、プレースホルダーの画像を置かなければなりませんでした。

ありがとうございます!

答えて

0

はい、あなたが使用しているライブラリについてしかし、あなたはこれを試すことができhdodenof年代でない、唯一無地の背景を使用することが可能である:

app:civ_fill_color="@android:color/white" 

また、あなたのCircularImageView

にこれを追加してみてください
android:layout_alignParentRight="true" 

android:layout_alignParentEnd="true"はRTLレイアウトのバックアップサポートとして、LTRの代わりにRTLからレイアウトをレンダリングするアプリケーションを作成する際に使用されます。

+0

恐ろしく、今すぐ動作します、ありがとうございます!ちょうど質問:私はそれに何かを入れていない場合CircularImageViewが消えます。単純な白い背景でそれを持つ方法はありますか? – Benny

+0

はいあります:hdodenhofのライブラリを使用している場合は、これを試してください: 'app:civ_fill_color =" @ android:color/white "' 私はあなたのためにうれしいです。 plsはそれを回答としてマークし、他の人もそれから利益を得ます。 – MadScientist

関連する問題