我已經在tab1中創建了一個應用程序與android studio相對佈局我有8個圖像,但是當我運行我的應用程序和滾動它滯後如何解決當我滾動滯後。當我滾動如何解決這個問題時,圖像滯後?
下面是代碼
package com.example.drh3cker.ihebski_swip;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.PagerTabStrip;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
//this project developped by iheb ben [email protected]
public class MainActivity extends FragmentActivity {
ViewPager pager;
PagerTabStrip tab_strp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_tab);
ma_pager_adapter mapager=new ma_pager_adapter(getSupportFragmentManager());
pager=(ViewPager)findViewById(R.id.pager);
pager.setAdapter(mapager);
tab_strp=(PagerTabStrip)findViewById(R.id.tab_strip);
tab_strp.setTextColor(Color.WHITE);
// tab_strp.setTextSize(14,14);
// tab_strp.setTabIndicatorColor(Color.WHITE);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.share) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void browser1(View view) {
Intent browserIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com"));
startActivity(browserIntent);
和
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:weightSum="1">
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/imageView"
android:src="@drawable/fra"
android:background="#f44437"
android:contentDescription="@string/App_Title_Image" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="150dp"
android:id="@+id/imageView2"
android:src="@drawable/saavnmusicapp"
android:paddingTop="8sp"
android:onClick="browser1"
android:contentDescription="@string/saavn_music_app"
android:scaleType="fitCenter"
android:layout_below="@+id/imageView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
style="?android:borderlessButtonStyle"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="150dp"
android:id="@+id/imageView3"
android:src="@drawable/earntalktime"
android:layout_below="@+id/imageView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:contentDescription="@string/earn_talktime_image"
android:onClick="browser2"
style="?android:borderlessButtonStyle"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="150dp"
android:id="@+id/imageView4"
android:src="@drawable/flipkart"
android:onClick="browser3"
android:contentDescription="@string/flipkart_app_image"
android:layout_below="@+id/imageView3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
style="?android:borderlessButtonStyle"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/imageView5"
android:layout_below="@+id/imageView4"
android:layout_centerHorizontal="true"
android:src="@drawable/paytmapp"
android:contentDescription="@string/paytm_app_image"
android:onClick="browser4"
style="?android:borderlessButtonStyle"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/imageView6"
android:layout_below="@+id/imageView5"
android:layout_centerHorizontal="true"
android:src="@drawable/uc"
android:onClick="browser5"
style="?android:borderlessButtonStyle"
android:contentDescription="@string/uc_browser_image" />
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/imageView7"
android:layout_below="@+id/imageView6"
android:layout_centerHorizontal="true"
android:src="@drawable/dailyhunt"
android:onClick="browser6"
style="?android:borderlessButtonStyle"
android:contentDescription="@string/uc_browser_image" />
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/imageView8"
android:layout_below="@+id/imageView7"
android:layout_centerHorizontal="true"
android:src="@drawable/freepaisa"
android:onClick="browser7"
style="?android:borderlessButtonStyle"
android:contentDescription="@string/uc_browser_image" />
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/imageView9"
android:layout_below="@+id/imageView8"
android:layout_centerHorizontal="true"
android:src="@drawable/mobikwik"
android:onClick="browser8"
style="?android:borderlessButtonStyle"
android:contentDescription="@string/uc_browser_image" />
</RelativeLayout>
</ScrollView>
#1是告訴我要添加更多的細節我不知道爲什麼我添加的問題和代碼和我想知道我怎麼能解決這個問題誰能幫助我
感謝。
@SarthakMittal他說,滾動條滯後。圖像在開始滾動之前被加載。我不認爲這個問題是在圖像內存大小。緩存庫不會解決問題。 – hasan83
@ hasan83對不起,我不好,我以爲OP使用了列表視圖 –