首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将下面的文本视图放到每个Imageview中?

如何将下面的文本视图放到每个Imageview中?
EN

Stack Overflow用户
提问于 2017-02-09 15:10:14
回答 1查看 32关注 0票数 0

我想到了布局权重的概念,需要在每个图像视图下面放置一个文本,我尝试了许多权重概念的方法,但textView正在发展,我在这里附上了我的xml,如果有人有建议,请提前给我一个解决this.Thanks的想法

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/topBar"
          style="@style/IconBar"
          android:layout_width="match_parent"
          android:layout_height="90dp"
          android:baselineAligned="true"
          android:orientation="horizontal"
          android:weightSum="4" >


<ImageButton
    android:id="@+id/home"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_weight="0.8"
    android:background="@android:color/transparent"
    android:src="@drawable/glow" 
    android:visibility="gone"/>

<RelativeLayout
    android:id="@+id/relative"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/imageLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_weight="0.8"
        android:src="@drawable/glow"/>

    <TextView
        android:id="@+id/textLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/imageLabel"
        android:layout_centerInParent="true"
        android:singleLine="true"
        android:text="Israel News"
        android:textSize="18sp"
        android:textStyle="bold"/>
</RelativeLayout>

<ImageButton
    android:id="@+id/email"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_weight="0.8"
    android:background="@android:color/transparent"
    android:src="@drawable/glow" />

<ImageButton
    android:id="@+id/place"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_weight="0.8"
    android:background="@android:color/transparent"
    android:src="@drawable/glow" />

<ImageButton
    android:id="@+id/account"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_weight="0.8"
    android:background="@android:color/transparent"
    android:src="@drawable/glow" />
<ImageButton
    android:id="@+id/accounts"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_weight="0.8"
    android:background="@android:color/transparent"
    android:src="@drawable/glow" />

</LinearLayout>
EN

Stack Overflow用户

发布于 2017-02-09 15:44:56

要在每个ImageView下应用TextView,需要将布局作为每个TextView的父项,并将ImageView作为子项

代码语言:javascript
复制
  <LinearLayout
        android:id="@+id/parent_home"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:weightSum="1">

        <ImageButton
            android:layout_weight="0.8"
            android:id="@+id/home"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:src="@drawable/glow" />

        <TextView
            android:layout_weight="0.2"
            android:id="@+id/homeText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:text="Email Text"/>

    </LinearLayout>
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42130355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档