[英]Textview being overlapped by Imageview
So I have a textview that I placed above an imageview. 所以我有一个textview放在imageview上方。 When I add text to the textview it is covered up by the imageview.
当我在textview中添加文本时,imageview将其覆盖。 What I want to happen is that when I add more text to the textview the imageview is pushed further down starting below the end of the text.
我想发生的是,当我向textview中添加更多文本时,imageview从文本末尾开始进一步向下推。 How would I go about accomplishing this?
我将如何实现这一目标?
Heres my activity_route_details.xml 这是我的activity_route_details.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_route_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.zach.listview.RouteDetails">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/routeDetailsView"
android:textSize="18sp"
android:textAlignment="center" />
<com.example.zach.listview.TouchImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/routeImage"
android:scaleType="fitCenter"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:adjustViewBounds="false" />
</RelativeLayout>
and heres my routeDetails.java 这是我的routeDetails.java
package com.example.zach.listview;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class RouteDetails extends AppCompatActivity {
TouchImageView routeImage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_route_details);
//back button for route details view
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//TextView for route details
final TextView routeDetailsView = (TextView) findViewById(R.id.routeDetailsView);
routeDetailsView.setText(getIntent().getExtras().getString("route"));
//ImageView for route details
routeImage = (TouchImageView) findViewById(R.id.routeImage);
routeImage.setImageResource(getIntent().getIntExtra("imageResourceId", 0));
}
//back button for route details view
@Override
public boolean onSupportNavigateUp(){
finish();
return true;
}
}
Add 加
android:layout_below="@+id/routeDetailsView"
to 至
<com.example.zach.listview.TouchImageView
definition in xml
. xml
<com.example.zach.listview.TouchImageView
定义。
Something like this: 像这样:
<com.example.zach.listview.TouchImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/routeImage"
android:scaleType="fitCenter"
android:layout_below="@id/routeDetailsView"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:adjustViewBounds="false"/>
Just put your code inside ScrollView
: 只需将您的代码放入
ScrollView
:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.