我有一个按钮,如下所示:
<Button
android:text="Submit"
android:id="@+id/Button01"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
Run Code Online (Sandbox Code Playgroud)
在我的onCreate()活动中,我这样调用Button01:
setContentView(R.layout.main);
View Button01 = this.findViewById(R.id.Button01);
Button01.setOnClickListener(this);
Run Code Online (Sandbox Code Playgroud)
应用程序中有一个背景,我想在此提交按钮上设置不透明度.如何为此视图设置不透明度?这是我可以在java端设置的东西,还是我可以在main.xml文件中设置?
在java方面,我试过Button01.mutate().SetAlpha(100),但它给了我一个错误.
当我单击列表活动中的项目时,我会显示一个弹出窗口.问题是后退键不会关闭它.我尝试在列表活动中捕获后退键但它没有注册它...然后我尝试将onkeylistener注册到我正在传递到弹出窗口的视图中.像这样:
pop.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
boolean res=false;
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
// do something on back.
Log.e("keydown","back");
if (pw.isShowing()) {
Log.e("keydown","pw showing");
pw.dismiss();
res = true;
}
} else {
res = false;
}
return res;
}
});
Run Code Online (Sandbox Code Playgroud)
传递给像这样的弹出窗口:
pw = new PopupWindow(
pop,
240,
70,
true);
Run Code Online (Sandbox Code Playgroud)
但那个听众既不会开火也不会开火.你能帮助我吗?我没有想法:)
我有一个View,它包含了包含它的Fragment之外的东西,我将它配置为使用它来绘制外部的内容.
问题是它可以在任何地方工作,但在ActionBar和ActionBar选项卡上.
mActionBar.addTab(
mActionBar.newTab()
.setCustomView(t));
Run Code Online (Sandbox Code Playgroud)
我正在使用appCompat并以这种方式添加标签:
我添加android:clipChildren="false"到所有父视图,但它不适用于ActionBar和ActionBar选项卡.
理想的观点:
我有一个习惯View用于我AlertDialog的标题和内容,这里是视图:
view_tip.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" style="@style/StandardLinearLayout"
android:layout_height="match_parent" android:layout_width="match_parent">
<TextView
android:maxWidth="245sp"
android:id="@+id/actionTip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我想AlertDialog包装它的内容.我一直在关注这个线程的解决方案:具有自定义视图的AlertDialog:调整大小以包装视图的内容,但它们都不适合我.
解决方案1,完全没有效果,AlertDialog占用整个空间:
// Scala code
val title = getLayoutInflater.inflate(R.layout.view_tip, null)
title.findViewById(R.id.actionTip).asInstanceOf[TextView] setText "title"
val view = getLayoutInflater.inflate(R.layout.view_tip, null)
view.findViewById(R.id.actionTip).asInstanceOf[TextView] setText "content"
val dialog = new android.app.AlertDialog.Builder(this).setCustomTitle(title).setView(view).show
dialog.getWindow.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
Run Code Online (Sandbox Code Playgroud)
forceWrapContent用于修改视图层次结构的解决方案2 对内容有影响,但标题不受影响:
// Scala code
val title = getLayoutInflater.inflate(R.layout.view_tip, null)
title.findViewById(R.id.actionTip).asInstanceOf[TextView] setText "title"
val view = getLayoutInflater.inflate(R.layout.view_tip, null)
view.findViewById(R.id.actionTip).asInstanceOf[TextView] setText "content"
val dialog = new android.app.AlertDialog.Builder(this).setCustomTitle(title).setView(view).show
forceWrapContent(title)
forceWrapContent(view) …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个Android蜂窝状弹出窗口,如谷歌文档应用程序我按照本教程,我能够获得弹出窗口,但如何使其成为模态窗口?如何创建图像中显示的边框效果

android ×5
popupwindow ×2
view ×2
android-ui ×1
button ×1
canvas ×1
layout ×1
opacity ×1
z-index ×1