ورود

View Full Version : روش کار با imageView در scrollview



AVR programmer
پنج شنبه 22 مهر 1395, 20:47 عصر
من میخواستم توی اکلیپس یه صفحه درست کنم که از یک عکس در بالا و نوشته طولانی در پایین تشکیل شده و و قتی اسکرول می کنیم عکس و نوشته ها برن بالا و به تدریج از صفحه خارج بشن ... اما هر کاری میکنم نمیشه داخل scrollview ایمیج ویو رو تعریف کنم عکس همیشه میره پایین
حتی از relativelayout هم استفاده کردم که برنامه در youwave ارور داد و معلوم نبود از چی ایراد گرفته . دوستان لطفا کمکم کنید . منتظر راهنمایی شما هستم :قلب:

spiderman200700
جمعه 23 مهر 1395, 09:39 صبح
لطفا کدهاتو بزرا که ببینیم مشکل از کجاس

AVR programmer
جمعه 23 مهر 1395, 16:03 عصر
لطفا کدهاتو بزرا که ببینیم مشکل از کجاس

البته در این برنامه imageview خارج از scrollview تعریف شده ولی من میخوام داخل scrollview باشه و image هم با نوشته ها اسکرول بشه بره بالا :

این از ebook0activity.java


package Ebook0.com.w3;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ScrollView;
import android.widget.TextView;




public class Ebook0Activity extends Activity {


TextView textView1;
Button button1;
Button button2;
String text2;
ScrollView scrollView1;




/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text2 = getResources().getString(R.string.text1);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
scrollView1 = (ScrollView) findViewById(R.id.scrollView1);


}




public void onbtn2click(View v)
{
textView1 = (TextView) findViewById(R.id.textView1);
//textView1.setMovementMethod(ScrollingMovementMetho d.getInstance());
textView1.setText(text2);
}
}

اینم از main.xml


<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >


<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onbtn1click"
android:text="صفحه بعدی" />


<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onbtn2click"
android:text="صفحه قبلی" />
</LinearLayout>


<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/camel" />


<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >


<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >


<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />


</LinearLayout>
</ScrollView>


</LinearLayout>


ضمنا من کدهای xml رو دستکاری نکردم .و همه چی رو با ابزارها ایجاد کردم .

spiderman200700
جمعه 23 مهر 1395, 17:20 عصر
باید ScrollView رو اینجوری بنویسی:
<ScrollView
android:id="@+id/scrollView1"
android:layout_height="match_parent"
android:layout_width="wrap_content">


<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">

<ImageView
android:id="@+id/imageView1"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:src="@drawable/camel" />


<TextView
android:id="@+id/textView1"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />


</LinearLayout>
</ScrollView>