所以我有一個textview,我放在imageview上方。當我將文本添加到textview時,它被imageview覆蓋。我想要發生的是,當我向文本視圖添加更多文本時,imageview會從文本末尾開始向下推動。我將如何去完成這件事?Textview被Imageview重疊
我的繼承人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>
和我的繼承人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;
}
}
感謝的作品完美。但現在我有一個問題,而不是imageview被推下來,頁面變得滾動,圖像只是縮小在同一屏幕上 – user4297729
嘗試更改'android:adjustViewBounds =「false」'到'android:adjustViewBounds =「 true「' –
或者使用'android:scaleType =」centerInside「'標籤。 –