Android计量单位有什么区别?
user-interface android units-of-measurement dimension android-layout
我的布局中有一个EditText和一个Button.
在编辑字段中写入并单击后Button,我想隐藏虚拟键盘.我假设这是一段简单的代码,但我在哪里可以找到它的一个例子?
android soft-keyboard android-layout android-softkeyboard android-input-method
我对两个XML属性有点困惑:match_parent和fill_parent.似乎两者都是一样的.它们之间有什么区别吗?
我知道我们可以为android:gravity和 android:layout_gravity属性设置以下值:
centercenter_verticalcenter_horizontal等但我对这两个问题感到困惑.
使用android:gravity和有android:layout_gravity什么区别?
Android Studio 0.4.5
用于创建自定义对话框的Android文档:http://developer.android.com/guide/topics/ui/dialogs.html
如果需要自定义对话框,则可以将"活动"显示为对话框,而不是使用"对话框API".只需创建一个活动并将其主题设置为<activity>清单元素中的Theme.Holo.Dialog :
<activity android:theme="@android:style/Theme.Holo.Dialog" >
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试这个时,我得到以下异常:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity
Run Code Online (Sandbox Code Playgroud)
我支持以下内容,我不能使用大于10的内容:
minSdkVersion 10
targetSdkVersion 19
Run Code Online (Sandbox Code Playgroud)
在我的风格中,我有以下内容:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
Run Code Online (Sandbox Code Playgroud)
在我的清单中,我有这个活动:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:theme="@android:style/Theme.Holo.Light.Dialog"
android:name="com.ssd.register.Dialog_update"
android:label="@string/title_activity_dialog_update" >
</activity>
Run Code Online (Sandbox Code Playgroud)
像我这样创建对话框是我要做的事情,因为我已经完成了布局.
谁能告诉我如何解决这个问题?
从最新的ADT版本开始,我注意到布局XML文件上的这个新属性,例如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity" />
Run Code Online (Sandbox Code Playgroud)
什么是"工具:上下文"用于?
它怎么知道写在那里的活动的确切路径?它是否在清单中查看应用程序的包?
它仅限于扩展Context或仅扩展活动的类吗?它可用于ListView项目等吗?
xml android android-context android-layout android-tools-namespace
我想隐藏一些活动的标题栏.问题是我将一个样式应用于我的所有活动,因此我不能简单地将主题设置为@android:style/Theme.NoTitleBar.
使用NoTitleBar主题作为我的样式的父级将从我的所有活动中删除标题栏.
我可以在某处设置无标题样式项吗?
我想稍微更改标准Android按钮的颜色,以便更好地匹配客户的品牌.
到目前为止,我发现这样做的最好方法是将Button'drawable'改为drawable,位于res/drawable/red_button.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/red_button_pressed" />
<item android:state_focused="true" android:drawable="@drawable/red_button_focus" />
<item android:drawable="@drawable/red_button_rest" />
</selector>
Run Code Online (Sandbox Code Playgroud)
但这样做需要我居然为每一个按钮,我想自定义三种不同的可绘制(一个用于按钮在休息,一个集中的时候,和一个按下时).这似乎比我需要的更复杂,更干燥.
我真正想做的就是对按钮应用某种颜色转换.是否有更简单的方法来改变按钮的颜色而不是我正在做的事情?
所以我想android:fontFamily在Android中更改,但我没有在Android中看到任何预定义的字体.如何选择其中一个预定义的?我真的不需要定义自己的TypeFace,但我所需要的只是它现在所显示的内容.
<TextView
android:id="@+id/HeaderText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="52dp"
android:gravity="center"
android:text="CallerBlocker"
android:textSize="40dp"
android:fontFamily="Arial"
/>
Run Code Online (Sandbox Code Playgroud)
看来我在那里做的不会真的有效!BTW android:fontFamily="Arial"是一次愚蠢的尝试!