我在相对布局中遇到问题。我在我的XML布局中设置了几个textviews,但在程序运行后,它们不会在模拟器/手机上显示文字。之前我认为这是Android Studio更新版本的问题。但我已经在另一台安装了旧版Android系统的计算机系统上进行了检查。我将XML代码分享给大家。请帮帮我。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/transition_profile"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/white">
<ImageView
android:id="@+id/imgv_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/round_arrow_back_ios_24_px"
android:layout_marginTop="54dp"
android:layout_marginLeft="28dp"
android:layout_alignParentLeft="true"/>
<ImageView
android:id="@+id/imgv_help"
android:layout_width="34dp"
android:layout_height="34dp"
android:src="@drawable/round_help_outline_24_px"
android:layout_alignParentRight="true"
android:layout_marginTop="54dp"
android:layout_marginRight="28dp"/>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imgv_boss"
android:layout_width="126dp"
android:layout_height="126dp"
android:src="@drawable/boss"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
android:layout_marginTop="71dp"/>
<TextView
android:id="@+id/tv_emp_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:textColor="#262d3d"
android:letterSpacing="0.02"
tools:text="Ramesh Singha"
android:fontFamily="@font/roboto_slab_bold"
android:layout_below="@id/imgv_boss"
android:layout_centerInParent="true"
android:layout_marginTop="26dp"/>
<TextView
android:id="@+id/tv_boss_profile_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#6c7383"
android:letterSpacing="0.02"
android:layout_below="@id/tv_emp_name"
tools:hint="Field Manager"
android:fontFamily="@font/roboto_slab_regular"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
<LinearLayout
android:id="@+id/ll_tabslides"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#fff"
android:layout_below="@id/tv_boss_profile_name">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tblyt_profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
app:tabIndicatorColor="#0091ea"
app:tabSelectedTextColor="#0091ea"
app:tabTextColor="#6c7383"
tools:targetApi="lollipop"/>
<androidx.viewpager.widget.ViewPager
android:id="@+id/vpgr_profile"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</RelativeLayout>
android:text
代替。 - John JoeTextView
并检查TextView是否可见。如果TextView
可见,则存在在RelativeLayout
中设置组件的问题。 - Fra Red