【问题标题】:Android-how to set image in particular layout starting center point?Android-如何在特定布局起始中心点设置图像?
【发布时间】:2016-11-23 05:45:37
【问题描述】:

我想设置如下图:

请帮我解决这个布局.. 提前致谢。

【问题讨论】:

  • 发布您的布局代码。
  • 你有什么尝试。发布您的 xml 代码
  • 您想在 Recycler 视图上对齐一半图像?
  • 这只是照片设计,我没有任何代码,但我想这样做.. @AndroidHacker

标签: android layout android-linearlayout android-relativelayout android-cardview


【解决方案1】:

基本

CardView 比 ImageView 有更高的高度。所以只要设置更高 ImageView 的高程。

我们开始..

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".activity.Splash"
    tools:showIn="@layout/activity_splash"
    >


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardUseCompatPadding="true"
        android:elevation="5dp"
        android:stateListAnimator="@anim/button_elevation"
        android:id="@+id/one"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        >

        <RelativeLayout
            android:orientation="vertical" android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="@dimen/activity_horizontal_margin"
            android:background="?attr/selectableItemBackground"

            >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="this is just for test"
                />

            </RelativeLayout>
    </android.support.v7.widget.CardView>


        <ImageView
            android:layout_marginRight="@dimen/activity_horizontal_margin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/cross"
            android:id="@+id/two"
            android:layout_centerVertical="true"
            android:elevation="10dp"
            />

</RelativeLayout>
</RelativeLayout>

还有屏幕截图....

【讨论】:

  • 很好的尝试,但从最后一张图片中删除海拔比这不起作用 - @AndroidHacker
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-07-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多