【问题标题】:ImageView With Button insideImageView 里面有按钮
【发布时间】:2016-04-20 14:27:36
【问题描述】:

我想用按钮在里面编辑照片来做 imageView 布局。

我想把图像作为 imageView 背景,但我不知道如何做半圆透明度和设置图标。

有什么想法吗?

更新

现在我有了这个。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="150dp"
android:layout_height="150dp"
android:background="@color/blue_bar">
<de.hdodenhof.circleimageview.CircleImageView
    android:id="@+id/image"
    android:scaleType="centerCrop"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@color/black"/>
<ImageButton
    android:layout_alignStart="@+id/image"
    android:layout_alignEnd="@+id/image"
    android:src="@drawable/ic_edit_photo"
    android:layout_alignParentBottom="true"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:background="#B3ffffff"/>
</RelativeLayout>

我可以将 imageButtons 背景做成半圆形吗?

【问题讨论】:

  • 你可以使用 FrameLayout

标签: android layout imageview profile


【解决方案1】:

为此,您必须制作一个 CompoundView。 1) 我将创建一个相对布局,将 imageview 的宽度和高度设置为 match_parent,然后将 alignBottom 设置为 true 的按钮。

2) 然后继续在 Activity 中正常使用按钮。

3) 您可以更高级地使用 CompoundView 扩展 ViewGroup 并放置按钮的功能。 这是它的教程: http://www.vogella.com/tutorials/AndroidCustomViews/article.html

希望对你有帮助。

【讨论】:

  • 按钮的背景怎么做?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-10-10
  • 2011-05-02
  • 2018-11-29
  • 1970-01-01
  • 1970-01-01
  • 2021-01-25
  • 1970-01-01
相关资源
最近更新 更多