TextView无法在相对布局中工作 [英] TextView is not working in relative layout
问题描述
我在Relative layout
中面临问题.我在XML布局中设置了几个textviews
,但是在运行程序it will not show the text on emulator/phone
之后.在我思考之前,这是android studio更新版本的问题.但是我还检查了另一台具有较旧android版本的计算机系统.我正在与大家共享XML代码.请帮我.
I am facing Problem In Relative layout
. I set several textviews
in my XML layout but after running the program, it will not show the text on emulator/phone
. Before I was thinking, this is the problem of the updated version of android studio. But I had also checked in another computer system with an older android version. I am sharing the XML code with you all. Please Help me.
<?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>
推荐答案
您正在textView
中使用tools:text="Ramesh Singha"
,用于测试目的.如果要设置文本,则应使用以下选项
You are using tools:text="Ramesh Singha"
in textView
and that is used for testing purpose. You should use following options if you want to set text
-
android:text="Ramesh Singha"
添加代码
<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 userName=(TextView)findViewById(R.id.tv_emp_name)
userName.setText("Ramesh Singha")
这篇关于TextView无法在相对布局中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!