【发布时间】:2017-09-22 22:31:12
【问题描述】:
我正在尝试使用 Android Studio 和 Firebase 构建我的第一个 Android 应用。我已将所有内容连接起来,它可以很好地显示数据库中的内容和 firebase 存储中的图像。问题是,由于某种原因,我添加到 xml 中的文本没有显示出来。在帖子的底部有 3 个按钮,“喜欢”、“评论”和“重新发布”,它们有一个图标,然后是它们旁边的文字。图标显示完美,但文本不会显示。 这是问题所在的“include_post_actions.xml”...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_below="@+id/post_action_layout"
android:layout_above="@+id/include"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_weight="1"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/post_action_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.like.LikeButton
app:icon_type="heart"
app:icon_size="18dp"
android:id="@+id/star_button"
android:layout_width="18dp"
android:layout_height="18dp" />
<TextView
android:id="@+id/post_likes_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="@color/colorBlack"
android:maxLines="1"
tools:text="Like" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="@+id/post_comment_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_question_answer_black_24dp" />
<TextView
android:id="@+id/post_comments_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="@color/colorBlack"
android:maxLines="1"
tools:text="Comment" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="@+id/post_repost_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_autorenew_black_24dp" />
<TextView
android:id="@+id/post_repost_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="@color/colorBlack"
android:maxLines="1"
tools:text="Repost" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/post_action_buttons">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:gravity="center_vertical"
tools:text="Likes Count"
android:id="@+id/like_count_text"
android:maxLines="1" />
</LinearLayout>
</RelativeLayout>
在预览中,文本显示在图标旁边,但是当我在模拟器上运行它时,只有图标在那里,我不知道为什么。请帮忙。谢谢你。 Android Studio 中的预览
【问题讨论】:
标签: java android android-layout android-studio