java - 如何忽略或禁用线性布局
问题描述
首先,我想做一个底部弹出,但我不知道如何忽略布局。我只想显示灰色布局。我正在尝试使其对白色布局透明,但它不起作用。我想我必须使用一些代码来忽略或删除它。我使用不可见的,这将使所有布局不可见。
这是我制作弹出窗口的代码
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_account, container, false);
backbutton1 = (ImageView) rootView.findViewById(R.id.backbutton1);
btnprofile = (Button) rootView.findViewById(R.id.btnprofile);
backbutton1.setOnClickListener(onClickListener);
btnprofile.setOnClickListener(onClickListener);
return rootView;
}
private View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
if(view == backbutton1) {
startActivity(new Intent(getActivity().getApplicationContext(), sidemenu.class));
getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
}if(view == btnprofile){
Bottom_sheet bottom_sheet = new Bottom_sheet();
bottom_sheet.show(getFragmentManager(), "examplebottomsheet");
}
}
};
Bottom_Sheet 类:
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.popout_chooseimage, container, false);
Button btnCancel = (Button) view.findViewById(R.id.buttonCancel);
Button btnRemove = (Button) view.findViewById(R.id.buttonRemove);
Button btnTake = (Button) view.findViewById(R.id.buttonTake);
Button btnLibrary = (Button) view.findViewById(R.id.buttonLibrary);
LinearLayout linear = (LinearLayout) view.findViewById(R.id.bottom_layout);
linear.setBackgroundResource(0);
btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
return view;
}
布局:
<LinearLayout
android:layout_width="800px"
android:layout_height="400px"
android:orientation="vertical"
android:background="@drawable/button_popout"
android:layout_marginBottom="10dp"
android:layout_gravity="center">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="100px"
android:background="@drawable/bottom_line">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change Profile Photo"
android:fontFamily="@font/seguisb"
android:textColor="@color/Black"
android:textSize="30px"
android:layout_centerInParent="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100px"
android:background="@drawable/bottom_line">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remove Current Photo"
android:textColor="@color/red"
android:fontFamily="@font/segoeui"
android:layout_centerInParent="true"/>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/buttonRemove"
android:background="@android:color/transparent"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100px"
android:background="@drawable/bottom_line">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Take A Photo"
android:textColor="@color/active_dots"
android:fontFamily="@font/segoeui"
android:layout_centerInParent="true"/>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/buttonTake"
android:background="@android:color/transparent"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Choose From Library"
android:textColor="@color/active_dots"
android:fontFamily="@font/segoeui"
android:layout_centerInParent="true"/>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/buttonLibrary"
android:background="@android:color/transparent"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="800px"
android:layout_height="wrap_content"
android:background="@drawable/button_popout"
android:layout_gravity="center">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:textSize="40px"
android:fontFamily="@font/seguibl"
android:layout_centerInParent="true"/>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/buttonCancel"
android:background="@android:color/transparent"/>
</RelativeLayout>
</LinearLayout>
输出将显示
解决方案
推荐阅读
- sql - 将随机列值应用于现有数据
- c# - 在 .NET Core 中不提供用户名和密码的 LDAP 连接
- laravel-5 - 调用未定义的方法 Illuminate\Database\Query\Builder::colFunction()
- string - 如何以某个字符开始字符串并以某个字符结束?(卢阿)
- javascript - IE11 存储空间不足,无法完成此操作
- c - 错误:source_file.c:5:32:致命错误:../include/externs.h:没有这样的文件或目录#include "../include/externs.h" ^ 编译终止
- ruby-on-rails - 当我需要不同版本时,如何解决需要最新版本 gem 的捆绑器问题?
- java - Spring 数据库初始化仅在应用程序重新启动后才有效
- typescript - 带有 WebStorm 的 Vue.js TypeScript 项目的调试器不会在断点处停止
- automation - 如何使用 JAVA 在一个会话中发送多封电子邮件