Skip to main content
Code Review

Return to Answer

Bounty Awarded with 50 reputation awarded by Community Bot
Improved readability, removed non-SE compliant fluff.
Source Link
Mast
  • 13.8k
  • 12
  • 57
  • 127

Its not that bad, but in this case you might have to test it in different screen sizes androidAndroid devices, to see if it fits exactly where you want.

In my opinion, better approach is to use FrameLayoutFrameLayout instead of using relative layout. By using frame layout, you can use gravity center | bottom and thereby removing marginTopmarginTop.

The code goes like this:

<FrameLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:gravity="center">
 <de.hdodenhof.circleimageview.CircleImageView
 android:layout_marginTop="25dp"
 android:id="@+id/imgProfilePicture"
 android:layout_width="110dp"
 android:layout_height="130dp"
 app:civ_border_width="1dp"
 app:civ_border_color="@color/colorPrimary"
 android:layout_gravity="center"/>
 <android.support.design.widget.FloatingActionButton
 android:id="@+id/fab"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignRight="@+id/imgProfilePicture"
 android:src="@mipmap/ic_launcher"
 app:elevation="2dp"
 app:fabSize="mini"
 android:layout_gravity="center|bottom"
 android:layout_marginLeft="50dp"
 />
</FrameLayout>

And this marginLeftmarginLeft 50dp is because , width if your circleImageViewcircleImageView is 110, so 50 is approxapproximately half where you want it.

Hope it helps

Its not that bad, but in this case you might have to test it in different screen sizes android devices, to see if it fits exactly where you want.

In my opinion, better approach is to use FrameLayout instead of using relative layout. By using frame layout, you can use gravity center | bottom and thereby removing marginTop.

The code goes like this:

<FrameLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:gravity="center">
 <de.hdodenhof.circleimageview.CircleImageView
 android:layout_marginTop="25dp"
 android:id="@+id/imgProfilePicture"
 android:layout_width="110dp"
 android:layout_height="130dp"
 app:civ_border_width="1dp"
 app:civ_border_color="@color/colorPrimary"
 android:layout_gravity="center"/>
 <android.support.design.widget.FloatingActionButton
 android:id="@+id/fab"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignRight="@+id/imgProfilePicture"
 android:src="@mipmap/ic_launcher"
 app:elevation="2dp"
 app:fabSize="mini"
 android:layout_gravity="center|bottom"
 android:layout_marginLeft="50dp"
 />
</FrameLayout>

And this marginLeft 50dp is because , width if your circleImageView is 110, so 50 is approx half where you want it.

Hope it helps

Its not that bad, but in this case you might have to test it in different screen sizes Android devices, to see if it fits exactly where you want.

In my opinion, better approach is to use FrameLayout instead of using relative layout. By using frame layout, you can use gravity center | bottom and thereby removing marginTop.

The code goes like this:

<FrameLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:gravity="center">
 <de.hdodenhof.circleimageview.CircleImageView
 android:layout_marginTop="25dp"
 android:id="@+id/imgProfilePicture"
 android:layout_width="110dp"
 android:layout_height="130dp"
 app:civ_border_width="1dp"
 app:civ_border_color="@color/colorPrimary"
 android:layout_gravity="center"/>
 <android.support.design.widget.FloatingActionButton
 android:id="@+id/fab"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignRight="@+id/imgProfilePicture"
 android:src="@mipmap/ic_launcher"
 app:elevation="2dp"
 app:fabSize="mini"
 android:layout_gravity="center|bottom"
 android:layout_marginLeft="50dp"
 />
</FrameLayout>

And this marginLeft 50dp is because , width if your circleImageView is 110, so 50 is approximately half where you want it.

Source Link
kukroid
  • 176
  • 3

Its not that bad, but in this case you might have to test it in different screen sizes android devices , to see if it fits exactly where you want.

In my opinion, better approach is to use FrameLayout instead of using relative layout. By using frame layout, you can use gravity center | bottom and thereby removing marginTop.

The code goes like this:

<FrameLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:gravity="center">
 <de.hdodenhof.circleimageview.CircleImageView
 android:layout_marginTop="25dp"
 android:id="@+id/imgProfilePicture"
 android:layout_width="110dp"
 android:layout_height="130dp"
 app:civ_border_width="1dp"
 app:civ_border_color="@color/colorPrimary"
 android:layout_gravity="center"/>
 <android.support.design.widget.FloatingActionButton
 android:id="@+id/fab"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignRight="@+id/imgProfilePicture"
 android:src="@mipmap/ic_launcher"
 app:elevation="2dp"
 app:fabSize="mini"
 android:layout_gravity="center|bottom"
 android:layout_marginLeft="50dp"
 />
</FrameLayout>

And this marginLeft 50dp is because , width if your circleImageView is 110, so 50 is approx half where you want it.

Hope it helps

default

AltStyle によって変換されたページ (->オリジナル) /