کلیدستان

نسخه‌ی کامل: عناصر گرافیکی لایوت (layout) (برنامه نویسی اندروید)
شما در حال مشاهده نسخه آرشیو هستید. برای مشاهده نسخه کامل کلیک کنید.
سلام
میشه بگید مشکل این سورس کجاست که نمی تونم تکست ویو مورد نظرم رو روی ایمیج ویو تنظیم کنم


کد پی‌اچ‌پی:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical" >

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

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="barname nevis"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#000"
            android:textSize="30sp" />

    </LinearLayout>

</ScrollView> 

یعنی میخام داخل اکتیویتی یه عکسی نمایش بدم و داخل اون عکس یه متنی رو قرار بدم
ولی هرکاری میکنم نمیتونم این تکست ویو رو داخل اون تصویرم بیارم


مشکل کجاست دوستان؟؟
سلام

مشکل شما در استفاه از Layout مناسب هستش
باید برای انجام این کار از یکی از 3 Layout زیر استفاده کنید 

FrameLayout
AbsoluteLayout
RelativeLayout


که برای مثال من از RelativeLayout استفاده کردم

کد:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
               android:id="@+id/scrollView1"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:background="@drawable/j" >

       <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                       android:layout_width="match_parent"
                       android:layout_height="match_parent"
                       android:orientation="vertical" >

           <ImageView
               android:id="@+id/splash_imageview"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:layout_centerInParent="true"
               android:scaleType="centerCrop" />

           <TextView
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:layout_gravity="center_horizontal"
               android:layout_marginBottom="20dip"
               android:layout_centerInParent="true"
               android:background="#AA000000"
               android:padding="12dip"
               android:text="SomeText"
               android:textColor="#ffffffff" />

       </RelativeLayout>

   </ScrollView>
اقا دستت درد نکنه
میشه اینو بهم بگید که قابلیتlinerLayoutکجا به درد میخوره؟ بهترین چیدمان بنظرم  RelativeLayoutهست چون هرجوری که بخوای میشه عناصر رو جابه جا کرد
سلام خواهش میکنم

بستگی به برنامه و طراحی Layout شما داره
در جاهایی که طراحی ساده و عناصر کمی در طرح Layout خودتون دارید Linearlayout گزینه مناسیبه
در مواردی که نیاز به طراحی انعطاف فپذیرتر و بهتر و عناصر بیشنری دارید گزینه Relativelayout مناسب هستش
در برخی موارد خاص مانند بالا Framelayout میتونه گزینه مناسبی باشه

در هر صورت شما بابد نحوه استفاده از Layout های پرکاربرد رو بلد باشید تا در مواقع نیاز از اونها استفاده کنید
موفق و پیروز باشید