小编Vin*_*ins的帖子

如何在android xml中使用自定义字体?

如何使用我的xml资产文件夹中添加的自定义字体?我知道我们可以setTypeface()在java中使用方法,但我们必须在我们使用它的地方执行此操作TextView.那么还有更好的方法吗?

android textview android-layout

25
推荐指数
1
解决办法
6万
查看次数

不同文本大小适用于不同硬件

我有一个编辑文本布局如下,我想知道,有没有办法根据屏幕大小为不同的硬件提供不同的大小?对于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

14
推荐指数
1
解决办法
2万
查看次数

为什么textStyle italic在Android布局中不应用于其他字体而不是serif?

以下是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则不显示.

这是为什么?

java android android-layout

12
推荐指数
1
解决办法
3167
查看次数

不同语言的不同维度

我正在开发一个项目,在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的大小.

android android-layout

6
推荐指数
1
解决办法
474
查看次数

如何在android中垂直跨越按钮/布局?

我有一个像计算器一样的布局,每行有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)

布局太长所以我在这里只分享第一行的代码,剩下的行也是一样的.

android android-layout android-linearlayout

5
推荐指数
1
解决办法
4008
查看次数

两个小部件在线性布局中紧挨着另一个小部件

我觉得很难实现,两个小部件(说旋转器)线性布局一个接一个.我的意思是两个微调器的布局高度是包裹内容,但宽度应该是第一个微调器的前半部分,屏幕的后半部分到第二个微调器.在线性布局中,它们一个接一个.我在相对布局中尝试过,但是当我给出宽度作为wrap_content时,它们彼此相邻,但是很多空间仍然是第二个微调器.我已经在很少的应用程序中看到了这个问题,但是我没有得到它.

在此输入图像描述

android android-layout android-spinner

3
推荐指数
1
解决办法
2898
查看次数

如何在android中获得max X和Max Y点?

我正在使用

RectF(float left, float top, float right, float bottom)
Run Code Online (Sandbox Code Playgroud)

创建一个矩形.对于一些最大x值和最大值超出屏幕.但是屏幕内部存在相同的值,用于某些大屏幕.所以无论如何要检查当前屏幕的最大值是什么,以便我可以使用屏幕内的坐标.

android android-emulator android-animation android-layout

2
推荐指数
1
解决办法
3118
查看次数

为什么Java在浮点计算后会显示额外的值?

我在下面有一段非常简单的代码,我认为从用户的角度给出了错误的结果.

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哪个是完美的价值.

java math

0
推荐指数
1
解决办法
807
查看次数

背景大小变化了

我正在以编程方式更改按钮的背景颜色,如下所示

     Button button =(Button)findViewById(R.id.one);
    button.setBackgroundColor(0xFFFF0000);
Run Code Online (Sandbox Code Playgroud)

但在此之后按钮的大小增加..我在UI中使用相对布局.

user-interface android android-layout

0
推荐指数
1
解决办法
1010
查看次数

代码中没有反映的按钮的颜色变化

我正在尝试在代码中更改按钮的颜色,如下所示

 btn_no5.setTextColor(0x8E35EF);
Run Code Online (Sandbox Code Playgroud)

上述变化未反映(紫色),执行上述代码后文本消失.但是,如果我使用xml中的颜色反映它.那么如何通过java改变这个呢?

android android-layout android-button

0
推荐指数
1
解决办法
274
查看次数

ICS就像以前版本的android中的微调器一样

我希望微调器在所有先前版本的2.2以上版本的Android中看起来像ICS一样.你知道有任何项目或样品吗?我来到HoloEverywhere项目

但它包含很多变化,这使我的应用程序规模庞大.所以你知道我可以使用的任何简单的变化.自定义layut可以帮助我,但我怎样才能获得ICS资源?

android android-layout

0
推荐指数
1
解决办法
2754
查看次数