如何使用我的xml资产文件夹中添加的自定义字体?我知道我们可以setTypeface()
在java中使用方法,但我们必须在我们使用它的地方执行此操作TextView
.那么还有更好的方法吗?
我有一个编辑文本布局如下,我想知道,有没有办法根据屏幕大小为不同的硬件提供不同的大小?对于4英寸以下的屏幕,我想给出以下布局
<EditText
android:id="@+id/entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:textColor="#800080"
android:text=""
android:hint=" No Operator Precednce yet"
android:cursorVisible="false"
android:textSize="40dip"
/>
Run Code Online (Sandbox Code Playgroud)
然后为其他人
<EditText
android:id="@+id/entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:textColor="#800080"
android:text=""
android:hint=" No Operator Precednce yet"
android:cursorVisible="false"
android:textSize="30dip"
/>
Run Code Online (Sandbox Code Playgroud) 以下是android:textStyle="italic"
未应用的简单xml片段.
如果我删除android:textStyle="italic
文本将出现.
<TextView
android:text="row one"
android:textSize="15pt"
android:typeface="serif"
android:textStyle="italic"
android:textColor="#00abcd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
Run Code Online (Sandbox Code Playgroud)
在上面android:textStyle="italic"
只是为了工作android:typeface="serif"
,如果我将字体改为sans,monospace或normal android:text
则不显示.
这是为什么?
我正在开发一个项目,在textview中,文本的维度在值为1024x768的文件夹中的main_dimens.xml文件中提到.但是我需要为特定语言使用不同的文本大小(例如pt).
<dimen name="main_digitalclock_size">18dp</dimen>
Run Code Online (Sandbox Code Playgroud)
我需要12dp的pt语言.所以我试着在values-pt文件夹的strings.xml中添加上面的代码行,还创建了一个文件夹值-pt-1024x768并在其中插入.但仍然只有18dp的大小.
我有一个像计算器一样的布局,每行有4个按钮,有5行.我通过使用创建了这些每一行LinearLayout
.我已经设法通过使用android:layout_weight="1"
每个按钮完全填充每行的宽度LinearLayout
.但我不知道如何以这种方式填补垂直空间.在五行之后,普通XDPI屏幕(Nexus 4)底部留有空间
<LinearLayout
android:id="@+id/first_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/entry">
<Button
android:id="@+id/seven"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="7"
android:textColor="@color/Blue_ICS"
android:textSize="@dimen/button_text_size"
/>
<Button
android:id="@+id/eight"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="8"
android:textColor="@color/Blue_ICS"
android:textSize="@dimen/button_text_size"/>
<Button
android:id="@+id/nine"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="9"
android:textColor="@color/Blue_ICS"
android:textSize="@dimen/button_text_size"/>
<Button
android:id="@+id/plus"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="+"
android:textColor="@color/Blue_ICS"
android:textSize="@dimen/button_text_size"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
布局太长所以我在这里只分享第一行的代码,剩下的行也是一样的.
我觉得很难实现,两个小部件(说旋转器)线性布局一个接一个.我的意思是两个微调器的布局高度是包裹内容,但宽度应该是第一个微调器的前半部分,屏幕的后半部分到第二个微调器.在线性布局中,它们一个接一个.我在相对布局中尝试过,但是当我给出宽度作为wrap_content时,它们彼此相邻,但是很多空间仍然是第二个微调器.我已经在很少的应用程序中看到了这个问题,但是我没有得到它.
我正在使用
RectF(float left, float top, float right, float bottom)
Run Code Online (Sandbox Code Playgroud)
创建一个矩形.对于一些最大x值和最大值超出屏幕.但是屏幕内部存在相同的值,用于某些大屏幕.所以无论如何要检查当前屏幕的最大值是什么,以便我可以使用屏幕内的坐标.
我在下面有一段非常简单的代码,我认为从用户的角度给出了错误的结果.
package com.test.sample;
public class Test {
public static void main(String[] args) {
float c,d;
c = (float) 12.47;
d = (float) 12.44;
d = c - d;
System.out.println("Hello the calculated value of a=" + d);
}
}
Run Code Online (Sandbox Code Playgroud)
输出是
Hello the calculated value of a=0.030000687
但我想要a=0.030000000
哪个是完美的价值.
我正在以编程方式更改按钮的背景颜色,如下所示
Button button =(Button)findViewById(R.id.one);
button.setBackgroundColor(0xFFFF0000);
Run Code Online (Sandbox Code Playgroud)
但在此之后按钮的大小增加..我在UI中使用相对布局.
我正在尝试在代码中更改按钮的颜色,如下所示
btn_no5.setTextColor(0x8E35EF);
Run Code Online (Sandbox Code Playgroud)
上述变化未反映(紫色),执行上述代码后文本消失.但是,如果我使用xml中的颜色反映它.那么如何通过java改变这个呢?
我希望微调器在所有先前版本的2.2以上版本的Android中看起来像ICS一样.你知道有任何项目或样品吗?我来到HoloEverywhere项目
但它包含很多变化,这使我的应用程序规模庞大.所以你知道我可以使用的任何简单的变化.自定义layut可以帮助我,但我怎样才能获得ICS资源?