【发布时间】:2014-06-18 12:54:34
【问题描述】:
我想在处理请求时用进度条替换图像按钮。
这是我的 XML
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/gap_normal"
android:orientation="horizontal"
android:background="0000000000">
<com.devspark.robototextview.widget.RobotoTextView
android:id="@+id/conference_text_lockstate"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/gap_normal"
android:layout_marginBottom="@dimen/gap_normal"
android:gravity="left"
android:textSize="@dimen/textsize_normal"
android:paddingRight="@dimen/gap_large"
android:text="Unlocked. When all participants have joined, lock the conference by tapping the padlock."
app:typeface="roboto_condensed_regular" />
<ImageButton
android:id="@+id/conference_checkableimagebutton_lockstate"
android:layout_width="60dp"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:background="@android:color/white"
android:src="@drawable/conference_checkableimagebutton_lockstate_src"
android:cropToPadding="false"/>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/pb"
android:indeterminate="true"
android:visibility="invisible"
/>
</LinearLayout>
我尝试在 onClick 方法中将 Image 按钮与 progressBar 交换。
if (mLockCheckableImageButton.isChecked()==true){
mLockCheckableImageButton.setClickable(false);
ProgressBar pb = (ProgressBar)inflated.findViewById(R.id.pb);
pb.setVisibility(View.VISIBLE);
//more code here.
但这会使它们彼此相邻。任何人?提前谢谢你。
【问题讨论】:
-
使用相对或框架布局...
-
如果你只想替换,那么你忘了调用 mLockCheckableImageButton.setVisibility(View.GONE);
标签: android xml mobile android-studio