【发布时间】:2020-12-17 10:54:36
【问题描述】:
我从 android 开始,但我正在做一个项目,要求我做与下图相同的事情。但是我不知道如何分析这个观点才能产生类似的东西。 从我在活动中看到的内容来看,我有一个“按钮”,当我点击它时,“按钮”中的元素会发生变化。有人可以向我解释如何剪切视图和元素来做同样的事情吗?提前感谢您的回答。
图片:
【问题讨论】:
标签: android android-layout android-fragments
我从 android 开始,但我正在做一个项目,要求我做与下图相同的事情。但是我不知道如何分析这个观点才能产生类似的东西。 从我在活动中看到的内容来看,我有一个“按钮”,当我点击它时,“按钮”中的元素会发生变化。有人可以向我解释如何剪切视图和元素来做同样的事情吗?提前感谢您的回答。
图片:
【问题讨论】:
标签: android android-layout android-fragments
我会给你一个粗略的想法..
它不是一个按钮,它是一个包含 2 个文本视图、2 个图像视图和一个搜索栏的布局,我建议您使用线性布局。在其上添加一个 clicklistner。
要在单击布局后更改元素,您必须获取其元素 textview 等的引用,并自行更改它们。 ex- seekbar.setprogress(30) 近似为您点击后的图片。
xml..
Linearlayout
textview
imageview and textview
imageview
seekbar
\Linearlayout
【讨论】:
@Miina Neko 在卡片视图中使用卡片视图在卡片视图中使用线性布局(或您喜欢的任何其他布局)在下面的代码中使用我为您制作的布局
<androidx.cardview.widget.CardView
app:cardCornerRadius="@dimen/_5sdp"
app:cardElevation="@dimen/_5sdp"
app:cardBackgroundColor="@color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:padding="@dimen/_5sdp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/refresh_btn"
android:layout_width="@dimen/_10sdp"
android:layout_height="match_parent" />
<TextView
android:layout_marginLeft="@dimen/_5sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="arrrarrr-raaar"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="@dimen/_3sdp"
android:layout_marginBottom="@dimen/_3sdp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_marginRight="@dimen/_5sdp"
android:src="@drawable/refresh_btn"
android:layout_width="@dimen/_10sdp"
android:layout_height="@dimen/_10sdp" />
<ImageView
android:layout_marginLeft="@dimen/_5sdp"
android:src="@drawable/refresh_btn"
android:layout_width="@dimen/_10sdp"
android:layout_height="@dimen/_10sdp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:layout_marginRight="@dimen/_5sdp"
android:layout_marginLeft="@dimen/_5sdp"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
注意:“@dimen/_sdp”是一个库,我正在共享链接并根据您的选择更改您的可绘制对象,并在 java 或 kotlin 中更改 ID,然后在单击或执行任何操作时以编程方式(如第二张图片)希望回答您题.. SDP库链接https://github.com/intuit/sdp
【讨论】: