2016-09-06 2 views
-5

텍스트 뷰에 링크를 추가했는데, 어떤 이유로 전체 텍스트 뷰가 화면 중앙에 위치하게됩니다. 잘못된 게재 위치를 보여주는 이미지를 추가했습니다.화면에 텍스트 뷰가 있어야합니다.

이유는 무엇이며 어떻게 해결할 수 있습니까?

enter image description here

:이 텍스트 뷰의 잘못된 위치를 표시하는 이미지가

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context="com.example.rodekruis.Folders" > 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left" 
     android:layout_marginBottom="20dp" 
     android:layout_marginLeft="1dp" 
     android:src="@drawable/rkz_logo" /> 

    <ImageView 
     android:id="@+id/imageButton1" 
     android:layout_width="40dp" 
     android:layout_height="50dp" 
     android:layout_marginBottom="20dp" 
     android:layout_marginRight="40dp" 
     android:layout_marginTop="10dp" 
     android:layout_gravity="right" 
     android:src="@drawable/informatiebutton" /> 
    </FrameLayout> 

    <ScrollView 
     android:id="@+id/scrollview" 
     android:layout_width="fill_parent" 
     android:layout_height="364dp" > 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="244dp" 
     android:layout_height="match_parent" 
     android:layout_marginTop="30dp" 
     android:layout_gravity="center" 
     android:text="@string/title_activity_folders" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="@color/black" /> 




</ScrollView> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_marginTop="15dp" 
     android:layout_alignParentBottom="true" 
     android:orientation="horizontal"> 

     <Button 
      android:id="@+id/button11" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginRight="5dp" 
      android:layout_weight="1" 
      android:text="Facebook" /> 

     <Button 
      android:id="@+id/button12" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_weight="1" 
      android:text="Youtube" /> 

     <Button 
      android:id="@+id/button13" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_alignLeft="@+id/button5" 
      android:layout_below="@+id/button8" 
      android:layout_marginLeft="5dp" 
      android:layout_weight="1" 
      android:text="Twitter" /> 

     <Button 
      android:id="@+id/button14" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_alignLeft="@+id/button5" 
      android:layout_below="@+id/button8" 
      android:layout_marginLeft="5dp" 
      android:layout_weight="1" 
      android:text="LinkedIn" /> 

    </LinearLayout> 
</LinearLayout> 

: 여기

package com.example.rodekruis; 
import android.net.Uri; 
import android.os.Bundle; 
import android.app.Activity; 
import android.content.Intent; 
import android.text.Html; 
import android.text.Spanned; 
import android.text.method.LinkMovementMethod; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 
import android.widget.AdapterView; 
import android.widget.Button; 
import android.widget.TextView; 

public class FoldersActivity extends Activity implements View.OnClickListener{ 


    TextView HyperLink; 
    Spanned Text; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_folders); 

     findViewById(R.id.button11).setOnClickListener(this); 
     findViewById(R.id.button12).setOnClickListener(this); 
     findViewById(R.id.button13).setOnClickListener(this); 
     findViewById(R.id.button14).setOnClickListener(this); 
     findViewById(R.id.imageButton1).setOnClickListener(this); 

     TextView textView =(TextView)findViewById(R.id.textView); 
     textView.setClickable(true); 
     textView.setMovementMethod(LinkMovementMethod.getInstance()); 
     String text = getResources().getString(R.string.title_activity_folders); 
     text += "<a href='https://www.rkz.nl/overzicht'> Klik daarvoor op deze link</a>"; 
     textView.setText(Html.fromHtml(text)); 


    } 

    @Override 
    public void onClick(View v) { 
     Intent intent = null; 
     switch (v.getId()) { 


      case R.id.button11: 
       Uri uri = Uri.parse("https://www.facebook.com/RKZ.BrandwondencentrumBeverwijk"); 
       intent = new Intent(Intent.ACTION_VIEW, uri); 
       break; 
      case R.id.button12: 
       Uri uri1 = Uri.parse("https://www.youtube.com/user/rodekruisziekenhuis/featured"); 
       intent = new Intent(Intent.ACTION_VIEW, uri1); 
       break; 
      case R.id.button13: 
       Uri uri2 = Uri.parse("https://twitter.com/rodekruiszh?lang=nl"); 
       intent = new Intent(Intent.ACTION_VIEW, uri2); 
       break; 
      case R.id.button14: 
       Uri uri3 = Uri.parse("https://www.linkedin.com/company/rode-kruis-ziekenhuis"); 
       intent = new Intent(Intent.ACTION_VIEW, uri3); 
       break; 
      case R.id.imageButton1: 
       intent = new Intent(FoldersActivity.this, InfoActivity.class); 
       break; 
     } 
     startActivity(intent); 
    } 

} 

내 XML 코드 : 여기

내 주요 활동 코드
+1

textview gravity = start –

+1

다음을 제거하십시오 : android : layout_gravity = "center"from textview – 1615903

+1

android : layout_gravity = "center"그것을 제거하고 Textview를 볼 위치를 설정하십시오. – MalhotraUrmil

답변

0

이 xml 코드를 시도하십시오. 대신 android:layout_gravity="center" 사용 01

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context="com.example.rodekruis.Folders" > 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left" 
     android:layout_marginBottom="20dp" 
     android:layout_marginLeft="1dp" 
     android:src="@drawable/rkz_logo" /> 

    <ImageView 
     android:id="@+id/imageButton1" 
     android:layout_width="40dp" 
     android:layout_height="50dp" 
     android:layout_marginBottom="20dp" 
     android:layout_marginRight="40dp" 
     android:layout_marginTop="10dp" 
     android:layout_gravity="right" 
     android:src="@drawable/informatiebutton" /> 
    </FrameLayout> 

    <ScrollView 
     android:id="@+id/scrollview" 
     android:layout_width="fill_parent" 
     android:layout_height="364dp" > 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="244dp" 
     android:layout_height="match_parent" 
     android:layout_marginTop="30dp" 
     android:layout_gravity="center_horizontal" 
     android:text="@string/title_activity_folders" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="@color/black" /> 
</ScrollView> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_marginTop="15dp" 
     android:layout_alignParentBottom="true" 
     android:orientation="horizontal"> 

     <Button 
      android:id="@+id/button11" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginRight="5dp" 
      android:layout_weight="1" 
      android:text="Facebook" /> 

     <Button 
      android:id="@+id/button12" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_weight="1" 
      android:text="Youtube" /> 

     <Button 
      android:id="@+id/button13" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_alignLeft="@+id/button5" 
      android:layout_below="@+id/button8" 
      android:layout_marginLeft="5dp" 
      android:layout_weight="1" 
      android:text="Twitter" /> 

     <Button 
      android:id="@+id/button14" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_alignLeft="@+id/button5" 
      android:layout_below="@+id/button8" 
      android:layout_marginLeft="5dp" 
      android:layout_weight="1" 
      android:text="LinkedIn" /> 

    </LinearLayout> 
</LinearLayout> 
+0

고마운 친구, 꽤 분명하지만, 나는 그것을 찾지 못했습니다. 건배 –

+0

모든 사람에게 일어납니다. 해피 코딩 .. –

0

텍스트 뷰의 마지막 이미지 뷰와 marginTop 및 layout_gravity의 marginBottom를 제거하십시오.

관련 문제