comment la moitié se chevauchent imageview sur un autre imageview dans Android
comment puis-je chevaucher les images moitié sur un autre à partir du fichier XML de mise en page comme cette image.
comment la moitié se chevauchent imageview sur un autre imageview dans Android
comment puis-je chevaucher les images moitié sur un autre à partir du fichier XML de mise en page comme cette image.
simplement vous pouvez utiliser RealtiveLayout
et des marges négatives
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_landing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/screen_background">
<ImageView
android:background="@color/black"
android:id="@+id/img_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_below="@+id/img_background"
android:layout_centerHorizontal="true"
android:layout_marginTop="-40dp"<!-- negative margin to half of height -->
android:src="@mipmap/ic_launcher" />
</RelativeLayout>
Ceci peut être réalisé facilement par RelativeLayout
mais vous devez regarder environ CoordinatorLayout
et ses caractéristiques.
Vous devez définir la marge supérieure avec moins (-) values.It chevauche votre point de vue de l'image avec d'autres
<RelativeLayout
android:layout_width="@dimen/_90sdp"
android:layout_height="@dimen/_90sdp">
<ImageView
android:id="@+id/bg"
android:layout_width="match_parent"
android:layout_height="@dimen/_90sdp"
android:background="@color/profile_bg"
android:scaleType="fitXY" />
<ImageView
android:id="@+id/img_user"
android:layout_width="@dimen/_80sdp"
android:layout_height="@dimen/_80sdp"
android:layout_below="@+id/bg"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/_minus50sdp"
android:src="@drawable/place_holder_profile"/>
</RelativeLayout>
Utilisez cette dépendances compilent « com.intuit.sdp: sdp-android: 1.0. 2' https://github.com/intuit/sdp
Le FrameLayout est plus optimisé pour effectuer cette fonction. Je porte moins de frais généraux.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_landing"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/img_background"
android:layout_width="match_parent"
android:layout_height="500dp"
android:src="@mipmap/ic_launcher"
android:background="@color/colorPrimary"/>
<ImageView
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_below="@+id/img_background"
android:layout_gravity="bottom|center_horizontal"
android:src="@mipmap/ic_launcher"
android:background="@color/cardview_dark_background"/>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/cc"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"
android:layout_centerInParent="true"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.4"
android:src="@drawable/a123123t"/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<!--blank space-->
</FrameLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image1"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/cc"
android:padding="8dp"
android:layout_gravity="center"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"
android:layout_centerInParent="true"
/>
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image2"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/cc"
android:padding="8dp"
android:layout_gravity="center"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"
android:layout_centerInParent="true"
/>
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image3"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/cc"
android:padding="8dp"
android:layout_gravity="center"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"
android:layout_centerInParent="true"
/>
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Edit Profile"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
pour les dépendances:
'Compile de.hdodenhof: circleimageview: 2.1.0'
de bien vouloir donne moi un petit exemple .. J'ai utilisé relativeLayout bt son image complète qui se chevauchent .. je vouloir chevaucher la moitié – Asad
une approche est donner une marge supérieure largerImageSize- (smallImageSize/2) à l'image circulaire – Spartan