【问题标题】:create customise button with image at top and text at bottom创建顶部图像和底部文本的自定义按钮
【发布时间】:2016-12-30 09:26:40
【问题描述】:

我指的是这个link,但它没有帮助

源代码

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/tools"
    xmlns:card_view="http://schemas.android.com/apk/res-auto">

    <data>

        <variable
            name="collection"
            type="com.techryde.bajafresh.data.model.local.CollectionDb" />
    </data>

    <RelativeLayout
        android:id="@+id/circle_layout"
        android:layout_width="160dp"
        android:layout_height="160dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/whitecircle">

        <RelativeLayout
            android:id="@+id/circle_layoutinner"
            android:layout_width="match_parent"
            android:layout_height="120dp"
            android:layout_above="@+id/rating_viewtv"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:background="@drawable/circle_inset_drawable">

            <ImageView
                android:id="@+id/country_photo"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                app:url="@{collection.imageUrl}" />


        </RelativeLayout>

        <TextView
            android:id="@+id/rating_viewtv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="3dp"
            android:text="@{collection.collectionName}"
            android:textColor="@android:color/white" />
    </RelativeLayout>
</layout>

whitecircle.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadius="0dp"
    android:shape="ring"
    android:thicknessRatio="2"
    android:useLevel="false">

    <solid android:color="@android:color/holo_red_dark" />

</shape>

circletwo.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadius="0dp"
    android:shape="ring"
    android:thicknessRatio="2"
    android:useLevel="false">

    <!--<solid android:color="#ff9546" />-->
    <solid android:color="#ffffff" />

</shape>

circle_insert_drawable.xml

<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/circletwo"
    android:insetTop="40dp"
    android:visible="true" />

不知道是什么问题?如果有人在此之前遇到过这个问题,那将是非常好的帮助。谢谢

【问题讨论】:

  • 尝试使用cardviews
  • 也使用过cardview。但也没有帮助。如果你能提供一些例子,那就太好了。谢谢

标签: android android-layout android-fragments android-linearlayout


【解决方案1】:

您可以轻松地创建带有可绘制顶部的按钮...

<Button android:layout_weight="wrap_content"
    android:layout_height="wrap_Content"
    android:drawableTop="@drawable/yourimage"
    android:background="your circle shap drawble"/>

【讨论】:

  • 那一点帮助。我想要底部的文字如图所示,上面部分的图像如图所示。
  • @AnkitOstwal drawble top 会在 Top 上放一张图片
  • 你将如何在文本后面显示红色背景以及底部的图像效果?
  • 你可以把颜色放在圆形drawble中
  • 我得到这样的输出.. dropbox.com/s/ghxh3hmcjauiz6m/… .. 但我想要如上面的问题所示。
猜你喜欢
  • 1970-01-01
  • 2012-12-08
  • 2015-02-07
  • 2010-10-05
  • 1970-01-01
  • 2012-06-09
  • 1970-01-01
  • 2021-12-23
  • 2023-02-21
相关资源
最近更新 更多