在本文中,我们将详细介绍XamarinAndroid-无法在预览中看到textview的各个方面,同时,我们也将为您带来关于(Android)XamarinFormsshell应用程序在最新的Xama
在本文中,我们将详细介绍Xamarin Android - 无法在预览中看到 textview的各个方面,同时,我们也将为您带来关于(Android) Xamarin Forms shell 应用程序在最新的 Xamarin 更新后崩溃、Android java.lang.ClassCastException:android.widget.LinearLayout无法强制转换为android.widget.TextView、android textview 字体加粗 Android studio 最新水平居中和垂直居中、android TextView 自动换行之后如果让每行的文本和图片都垂直居中,在这里我使用的 textview 显示 html的有用知识。
本文目录一览:- Xamarin Android - 无法在预览中看到 textview
- (Android) Xamarin Forms shell 应用程序在最新的 Xamarin 更新后崩溃
- Android java.lang.ClassCastException:android.widget.LinearLayout无法强制转换为android.widget.TextView
- android textview 字体加粗 Android studio 最新水平居中和垂直居中
- android TextView 自动换行之后如果让每行的文本和图片都垂直居中,在这里我使用的 textview 显示 html
Xamarin Android - 无法在预览中看到 textview
如何解决Xamarin Android - 无法在预览中看到 textview
难道我不能在左侧预览中从右侧看到 TextView 吗?
解决方法
启用加速渲染设置是问题所在:
(Android) Xamarin Forms shell 应用程序在最新的 Xamarin 更新后崩溃
如何解决(Android) Xamarin Forms shell 应用程序在最新的 Xamarin 更新后崩溃
所以我有一个 Xamarin Forms Shell 应用程序,Shellcontents 设置如下:
<Shell etc etc>
<ShellContent ContentTemplate="Temp1" Route="routeA" Title="titleA" />
<ShellContent ContentTemplate="Temp2" Route="routeB" Title="titleB" />
<MenuItem Text="{x:Static rx:AppResources.logout}" Command="{Binding logoutCommand}"/>
</Shell>
启动时,ShellContent A 显示一切正常。但是当我触摸 titleB 时,我收到了这个愚蠢的错误。 我一直无法弄清楚,这个错误来自哪里。有什么想法应该去哪里看?
No package ID ff found for ID 0xffffffff.
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] android.content.res.Resources$NotFoundException: Unable to find resource ID #0xffffffff
[AndroidRuntime] at android.content.res.ResourcesImpl.getResourceTypeName(ResourcesImpl.java:334)
[AndroidRuntime] at android.content.res.Resources.getResourceTypeName(Resources.java:2300)
[AndroidRuntime] at androidx.fragment.app.FragmentAnim.loadAnimation(FragmentAnim.java:79)
[AndroidRuntime] at androidx.fragment.app.DefaultSpecialEffectsController$AnimationInfo.getAnimation(DefaultSpecialEffectsController.java:774)
[AndroidRuntime] at androidx.fragment.app.DefaultSpecialEffectsController.startAnimations(DefaultSpecialEffectsController.java:144)
[AndroidRuntime] at androidx.fragment.app.DefaultSpecialEffectsController.executeOperations(DefaultSpecialEffectsController.java:120)
[AndroidRuntime] at androidx.fragment.app.SpecialEffectsController.executePendingOperations(SpecialEffectsController.java:294)
[AndroidRuntime] at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2190)
[AndroidRuntime] at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2088)
[AndroidRuntime] at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990)
[AndroidRuntime] at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
[AndroidRuntime] at android.os.Handler.handleCallback(Handler.java:938)
[AndroidRuntime] at androidx.fragment.app.DefaultSpecialEffectsController.startAnimations(DefaultSpecialEffectsControlleer.dispatchMessage(Handler.java:99)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:246)
[AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:8430)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596)
[AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
解决方法
我没有 Temp1
和 Temp2
。我创建了一个 Shell 模板来测试。它适用于我的身边。您可以查看下面的代码。
XML:
<ShellContent
Title="titleA"
ContentTemplate="{DataTemplate local:ItemsPage}"
Route="routeA" />
<ShellContent
Title="titleB"
ContentTemplate="{DataTemplate local:AboutPage}"
Route="routeB" />
<MenuItem Command="{Binding LogoutCommand}" Text="Page1" />
代码hebind:
,
public partial class AppShell : Xamarin.Forms.Shell
{
public ICommand LogoutCommand => new Command(async () => await Shell.Current.GoToAsync("page1"));
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute("page1",typeof(Page1));
this.BindingContext = this;
}
}
当我按照此处的提示将 Xamarin.Google.Android.Material 降级到 v1.2.1.1 时,我能够更正此错误:
https://github.com/xamarin/Xamarin.Forms/issues/13843
Android java.lang.ClassCastException:android.widget.LinearLayout无法强制转换为android.widget.TextView
我正在尝试打印listView中单击的值,但后来我得到以下异常:
07-04 10:40:56.482: E/AndroidRuntime(1356): FATAL EXCEPTION: main
07-04 10:40:56.482: E/AndroidRuntime(1356): java.lang.classCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
07-04 10:40:56.482: E/AndroidRuntime(1356): at com.passwordkeeper.ui.ActivityHomeScreen$1.onItemClick(ActivityHomeScreen.java:88)
这是一段代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mTextView = (TextView) findViewById(R.id.labelList);
db = new DatabaseHandler(this);
createList();
displayList();
}
createList函数正常工作.这是我的displayList方法:
public void displayList(){
this.setlistadapter(new ArrayAdapter<String>(this, R.layout.activity_home_screen, R.id.listTextView, mAccountNames));
mListView = getListView();
mListView.setonItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
String product = ((TextView) view).getText().toString();
Log.v("mSelectedProduct", product);
}
});
}
我的文件activity_home_screen.xml的xml代码是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/listTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="28dp"
android:layout_marginTop="26dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
任何帮助都会有用!
谢谢.
解决方法:
你可以试试这个
mListView.setonItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
TextView txtview = (TextView)view.findViewById(R.id.listTextView);
String product = txtview.getText().toString();
Log.v("mSelectedProduct", product);
}
});
android textview 字体加粗 Android studio 最新水平居中和垂直居中
android textview 字体加粗 Android studio 最新水平居中和垂直居中
Android 中字体加粗
在 xml 文件中使用 android:textStyle=”bold”
但是不能将中文设置成粗体,将中文设置成粗体的方法是:
TextView tv = (TextView)findViewById(R.id.TextView01);
TextPaint tp = tv.getPaint();
tp.setFakeBoldText(true);
取消加粗效果设置:
TextPaint tp = tv.getPaint();
tp.setFakeBoldText(false);
方法二:
textView.setTypeface (Typeface.defaultFromStyle (Typeface.BOLD));// 加粗
-------------
android textview 垂直居中
LinearLayout 分为水平分布、垂直分布:
android:orientation="vertical" // 垂直分布
android:orientation="horizontal" // 居中分布
<LinearLayout
// 下面 gravity 属性的参数:center 为居中,center_horizontal 为水平居中,center_vertical 为垂直居中
android:gravity="center|center_horizontal|center_vertical" >
注:android:gravity 和 android:layout_gravity 的区别在于前者对控件内部操作,后者是对整个控件操作。
例如:android:gravity="center" 是对 textView 中文字居中
android:layout_gravity="center" 是对 textview 控件在整个布局中居中
出现 "layout" 就是控件对整个布局的操作。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center|center_horizontal|center_vertical" >
// 上面 gravity 属性的参数:center 为居中,center_horizontal 为水平居中,center_vertical 为垂直居中
</LinearLayout>
注意:android:layout_width="fill_parent" android:layout_height="fill_parent" 属性中,若水平居中,至少在宽度上占全屏;若垂直居中,则在高度上占全屏
RelativeLayout 布局下的居中:
<RelativeLayout xmlns:Android="http://schemas.android.com/apk/res/android"
Android:layout_width="match_parent" Android:layout_height="match_parent">
<Button Android:id="@+id/btnxx" Android:layout_width="wrap_content"
Android:layout_height="wrap_content" Android:gravity="center_horizontal"
Android:textSize="20sp" Android:layout_alignParentBottom="true"
Android:layout_centerHorizontal="true" Android:text="back" />
</RelativeLayout>
Android:gravity="CENTER_VERTICAL":这个是垂直居中对齐
Android:gravity="BOTTOM":放在容器的底部
Android:gravity="CENTER" :放在容器的中心
android TextView 自动换行之后如果让每行的文本和图片都垂直居中,在这里我使用的 textview 显示 html
在 TextView 默认的情况下,显示的 html 如果是图文混排的时候是这种以底部对齐的,但是这样的效果不符合需求,但是看见猿题库这样的软件实现了 html 混排之后,每一行的图文混排文本都是垂直居中的。请问有什么解决,或者提供思路,求大大们来帮帮手!
我现在的效果是:
文本内容的文字与图片都不是垂直居中的,使用 TextView 显示 html 的 spanned,现在想要的效果就是每行的内容都是相对于每行的空间,垂直居中。
这是外国友人的回答:
如果根据外国友人的意思,那么我就要将 staticLayout 的源码重新修改,然后按照 textview 的 onDraw 方法来绘制内容,但是本人没有这么强的能力。
今天关于Xamarin Android - 无法在预览中看到 textview的分享就到这里,希望大家有所收获,若想了解更多关于(Android) Xamarin Forms shell 应用程序在最新的 Xamarin 更新后崩溃、Android java.lang.ClassCastException:android.widget.LinearLayout无法强制转换为android.widget.TextView、android textview 字体加粗 Android studio 最新水平居中和垂直居中、android TextView 自动换行之后如果让每行的文本和图片都垂直居中,在这里我使用的 textview 显示 html等相关知识,可以在本站进行查询。
本文标签: