我想应用一些字体说Times New Roman只适用于我的应用程序. 不是对整个系统而是对特定的观点.据我所知
要将字体应用于特定视图,我们将字体文件存储在资产文件夹中,并按如下方式进入应用程序.
1] Typeface mFace = Typeface.createFromAsset(getContext().getAssets(),
"fonts/samplefont.ttf");
textView.setTypeface(mFace);
2] To apply font to whole application I can replace the DroidSans.ttf file with my font file.
Run Code Online (Sandbox Code Playgroud)
我可以使用第一种方式将字体应用到我的应用程序,但它不是一个好的解决方案,因为我需要在任何地方进行修改,如果有更好的方法,我不想这样做.
我试图在我的Android应用程序中更改选项菜单的背景颜色.我正在使用ActionBarSherlock库.我试过这段代码来改变选项菜单的背景颜色
但我最终得到一个例外"java.lang.illegalstateexception:已经在此layoutinflater上设置了一个工厂"
LayoutInflater.setFactory();
我不知道这段代码有什么问题.任何人都可以帮我解决这个问题吗?
android background-color options-menu android-optionsmenu oncreateoptionsmenu
我需要确定TextView其基线距离容器底部20dp的方式.
我怎样才能做到这一点?
具有底部边距或填充的布局产生相同的结果.
我想把文字"坐"在紫线上.当我写'坐'时,我的意思是,'wert'应该接触线,而不是'q ... y'.
填充/边距等于紫色方形尺寸:

我有一个TextView我注册以下动画:
mScaleAnimation = new ScaleAnimation(1f, 1.2f, 1f, 1.2f,
mReferenceTextView.getWidth() / 2, mReferenceTextView
.getHeight() / 2);
mScaleAnimation.setRepeatCount(Animation.INFINITE);
mScaleAnimation.setRepeatMode(Animation.REVERSE);
mScaleAnimation.setDuration(500);
Run Code Online (Sandbox Code Playgroud)
它工作正常,看起来很酷:)
我唯一担心的是:当我看到logcat时,它完全无法使用,因为只要动画正在运行,我会不断地每秒多次获取这些日志:(
06-20 17:50:05.555: DEBUG/skia(14179): purging 213K from font cache [7 entries]
06-20 17:50:05.750: DEBUG/skia(14179): purging 196K from font cache [7 entries]
06-20 17:50:05.870: DEBUG/skia(14179): purging 202K from font cache [8 entries]
06-20 17:50:05.995: DEBUG/skia(14179): purging 190K from font cache [8 entries]
Run Code Online (Sandbox Code Playgroud)
在TextView使用自定义字体/字体(在OTF格式).
是什么原因导致字体缓存的繁重工作?
我有一个习俗,TextView它的名字是TextViewPlus。我想为我的自定义添加样式TextView。当我写这个时styles.xml它没有用。错误是:
错误:错误:找不到与给定名称匹配的资源:attr 'foo:customFont'。
这是styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources
xmlns:foo="http://schemas.android.com/apk/res/com.example">
<style name="textstyle" parent="@android:style/TextAppearance">
<item name="android:textSize">50sp</item>
<item name="foo:customFont">Fonts/BZar.ttf</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
请注意,我从自定义字体和 XML 布局 (Android)获取自定义 TextView
我想使用android中具有相同字体类型的所有组件,因为我正在为CustomTextView,CustomEditText等每个组件创建一个单独的自定义类.
因此,我可以创建一个视图CustomView类,它将自动为android中的所有组件应用样式,而不是为每个组件创建单独的类
我一直在谷歌搜索,但还没有找到解决方案.
我知道我可以TextView像这样以编程方式更改字体view.setTypeface(Typeface.createFromAsset(getAssets(),"dejavusans.ttf"));.
但是,有没有办法直接在xml文件中执行此操作?我找到了android:typeface属性,但它只有"普通","sans","serif"和"monospace"的选项.我怎样才能使用这种字体/assets/fonts/Roboto-Regular.ttf?
谢谢.
我有一个简单的列表视图与适配器.我动态创建了10多个listviewitems.然后我一次又一次地上下滚动......我可以看到可用的内存不断下降......
我需要在哪里免费?注意 - 有一个imageview - 但在我的测试中我没有使用任何图像,所以它是View.GONE.
另外 - 我可以使用哪个工具来分析android上的内存使用情况.我找到了你的Kit,但我如何为android配置它(我在设备上运行应用程序)/
Activity类
package org.BJ.Food4All.Activities.NewRecipe;
import org.BJ.Food4All.R;
import org.BJ.Food4All.Recipe;
import org.BJ.Food4All.Recipe.Instruction;
import org.BJ.Food4All.Activities.RecipeBook.RecipeInstructionsListViewAdapter;
import org.BJ.Food4All.Activities.RecipeBook.SharedData;
import org.BJ.Food4All.utils.CameraUtil;
import org.BJ.Food4All.utils.ImageUploadItem;
import android.app.ListActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.EditText;
public class Instructions extends ListActivity implements OnClickListener
{
private final static String mTAG = "Instructions";
private EditText mInstructionEditText = null;
private RecipeInstructionsListViewAdapter mListViewAdapter = null;
private Recipe mEditRecipe …Run Code Online (Sandbox Code Playgroud) 我想使用自定义字体文件.以下是我的代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/custom_font"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is the Chantelli Antiqua font." />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "Chantelli_Antiqua.ttf");
txt.setTypeface(font);
Run Code Online (Sandbox Code Playgroud)
它的工作.但我想在整个项目中使用这种自定义字体.
所以我必须放在一个所有Class都可以使用它的地方.不需要为每个人写TextView.
我在哪里以及如何使用此自定义字体.
我正在尝试使用自定义字体创建数字时钟小部件。
我从这里得到了线索
解决方案是通过扩展 TextView 并为自定义字体字体添加新属性。与绘制 Canvas 和 Bitmap 解决方案然后将其传递给 RemoteViews 相比,这是一个很好的解决方案。
我遵循了每一步,1. 创建自定义类 CustomFont.java 2. 在 attrs.xml 中定义样式 3. 然后将其放入 main.xml
但我收到以下错误
WARN/AppWidgetHostView(18681): updateAppWidget couldn't find any view, using error view
WARN/AppWidgetHostView(18681): android.view.InflateException: Binary XML file line #17: Error inflating class upper.duper.widget.circular.clock.CustomFont
...
...
...
WARN/AppWidgetHostView(18681): Caused by: java.lang.ClassNotFoundException: upper.duper.widget.circular.clock.CustomFont in loader dalvik.system.PathClassLoader
Run Code Online (Sandbox Code Playgroud)
少了什么?
这里我附上代码 这是 CustomFont.java
package upper.duper.widget.circular.clock;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.TextView;
public class CustomFont extends TextView {
private …Run Code Online (Sandbox Code Playgroud) 如何AnalogClock在app小部件中设置Android的自定义时间?
作为替代方案,我正在考虑覆盖默认的AnalogClock来设置代码的时间.换句话说,我会创建自定义时钟,它从默认的View或AnalogClock扩展.然后将我的自定义时钟放在小部件布局UI上.
这可能吗?我担心RemoteViews会限制我们自己的自定义组件.
更新: 这是错误日志我首先遵循vArDo给出的解决方案.

我想在Android应用程序中使用新的自定义字体.请在解释时准确而具体,我是新手.也就是说,我想让我的Android应用程序使用这些新的Android自定义字体http://developer.android.com/design/style/typography.html.谢谢.请帮忙.
android ×12
fonts ×3
layout ×2
widget ×2
components ×1
java ×1
listview ×1
memory ×1
memory-leaks ×1
options-menu ×1
textview ×1
view ×1