我遇到了一个问题,因为即使第一个TextView有几行文本,我也希望两个TextView并排布局.理想情况下,下一个TextView应该紧跟在之后.这有点难以解释,所以我用这张照片来说明它:

(第一个TextView包含标题,第二个TextView包含一年)
我现在一直在尝试一些不同的东西,包括布局黑客和使用Html.fromHtml(),但到目前为止还没有任何工作.这可能是不可能的,但我只是想确定.
我有一个关于向textview添加多个自定义字体的问题.我基本上已经在fonts文件夹中添加了字体,并基于我在网上找到的解决方案为fonttextview创建了一个java类.但是我看到他们只添加了一种字体,我想添加多种字体,如roboto-regular,roboto-bold,cab-bold等.这是我到目前为止的代码:
public class FontTextView extends TextView {
public FontTextView(Context context) {
super(context);
Typeface face=Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Bold.ttf");
this.setTypeface(face);
}
public FontTextView(Context context, AttributeSet attrs) {
super(context, attrs);
Typeface face=Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Bold.ttf");
this.setTypeface(face);
}
public FontTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
Typeface face=Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Bold.ttf");
this.setTypeface(face);
}
Run Code Online (Sandbox Code Playgroud)
如何创建多种字体呢?此外,我尝试了样式等,但它显示错误,因为它不支持可定制的类,任何人都可以添加另一种字体到这个现有的代码并引导我完成检索过程?
谢谢!贾斯汀
android android-emulator android-intent android-layout android-listview
我想在单个文本视图中为ex"RedBlueGray"显示一个字符串,例如Red应该显示红色字体颜色,蓝色显示蓝色字体,灰色显示灰色字体.这可能吗?如果是这样,最好的方法是什么.请注意,我想要显示的字符串将动态更改,但不会更改颜色.
我使用Android Studio.我想在下面的照片中写出彩色文字EditText.我研究过,但我什么都没发现.谁能帮我?
样本输出如下.
这是我的代码.anaM_LV_BG_text是列表视图name_title,内容是edittextrenk_koduları_string_text是一个包含html颜色的数组
private void registerClickCallBack_text(){anaM_LV_BG_renk_text.setOnItemClickListener(new AdapterView.OnItemClickListener(){
private void registerClickCallBack_text() {
anaM_LV_BG_renk_text.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(DisplayNote.this, position + 1 + " . seçildi", Toast.LENGTH_SHORT).show();
name_title.setTextColor(Color.parseColor(renk_kodular?_string_text[position]));
content.setTextColor(Color.parseColor(renk_kodular?_string_text[position]));
SharedPreferences preferences_text = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor_text = preferences_text.edit();
String color_text= renk_kodular?_string_text[position];
editor_text.putString("MyColorText",color_text);
editor_text.commit();
}
});
}
Run Code Online (Sandbox Code Playgroud)