[英]How can I achieve Image slightly on top linear layout border?
I am trying to show top critics list as horizontal scrolling cards and each card as shown in attached image . 我试图显示如图附顶级评论家列表,水平滚动卡,每张卡的图像 。 User picture should be slightly over the layout border, I tired
用户图片应该稍微超出布局边框,我很累
android:layout_marginTop="-15dp"
android:layout_marginTop =“-15dp”
but it is cutting top of the image. 但这是最重要的。
Here is the code I have: Any help is appreciated, Thanks in advance. 这是我的代码:感谢您的帮助,在此先感谢。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/my_shape"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/cardrank"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="top|start"
android:layout_marginTop="-15dp"
android:layout_weight="1"
android:src="@drawable/test" />
<TextView
android:id="@+id/cardtitle"
style="@style/TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:layout_weight="3"
android:gravity="center"
android:text="Card title"
android:textColor="#cc0000"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
style="@style/TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="30"
android:textStyle="bold" />
<TextView
android:id="@+id/cardfollowers"
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="followers"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@android:color/darker_gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
style="@style/TextAppearance.AppCompat.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="30"
android:textStyle="bold" />
<TextView
android:id="@+id/cardreviews"
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="reviews"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/cardfollowbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="Follow" />
</LinearLayout>
You could just add another layer of Views to wrap your root view, for example, RelativeLayout. 您可以只添加另一层Views来包装您的根视图,例如RelativeLayout。 Inside, one view will be your root view with my_shape background and the seconds will be the image.
在内部,一个视图将是具有my_shape背景的根视图,秒将是图像。
In RelativeLayout the order of the items on the Z axis will their order in the XMl, so the image will be on top of the my_shape layout. 在RelativeLayout中,项目在Z轴上的顺序将是它们在XMl中的顺序,因此图像将位于my_shape布局的顶部。
Then just adjust the image to the right location above the my_shape view. 然后,只需将图像调整到my_shape视图上方的正确位置即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.