我想知道我是否可以通过全屏视频播放视频?
我经常搜索并尝试了很多方法,例如:
在清单中应用主题:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
Run Code Online (Sandbox Code Playgroud)
但这并不会强制视频全屏显示.
申请活动本身:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)
也不会强制视频全屏显示.
强制视频全屏显示的唯一方法是:
<VideoView android:id="@+id/myvideoview"
android:layout_width="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_height="fill_parent">
</VideoView>
Run Code Online (Sandbox Code Playgroud)
这样它就会产生全屏视频,但它会延伸视频本身(拉长视频),
我没有将这个不正确的解决方案应用到我的视频中,所以有没有办法在不延长视频的情况下进行操作?
视频课程:
public class Video extends Activity {
private VideoView myvid;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
myvid = (VideoView) findViewById(R.id.myvideoview);
myvid.setVideoURI(Uri.parse("android.resource://" + getPackageName()
+"/"+R.raw.video_1));
myvid.setMediaController(new MediaController(this));
myvid.requestFocus();
myvid.start();
}
}
Run Code Online (Sandbox Code Playgroud)
main.xml中:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<VideoView
android:id="@+id/myvideoview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我在我的应用上创建了Preference活动,允许用户启动/停止背景启动画面音乐,如下所示:
public class Prefs extends PreferenceActivity{
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
}
}
Run Code Online (Sandbox Code Playgroud)
在xml文件夹中创建prefs.xml:
<?xml version="1.0" encoding="utf-8" ?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:title="splash music"
android:defaultValue="true"
android:key="checkbox"
android:summary="Plese remove music "/>
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
这个代码用于启动活动:
public class Splash extends Activity{
MediaPlayer ourSong;
@Override
protected void onCreate(Bundle Drandroid) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// TODO Auto-generated method stub
super.onCreate(Drandroid);
setContentView(R.layout.splash);
ourSong = MediaPlayer.create(Splash.this, R.raw.splashsound);
SharedPreferences getPrefs =
PreferenceManager.getDefaultSharedPreferences(getBaseContext());
boolean music = getPrefs.getBoolean("checkbox", true);
if (music == true)
ourSong.start(); …
Run Code Online (Sandbox Code Playgroud) 如Google所述,Gallery类在API级别16中已弃用.不再支持此小部件.其他水平滚动小部件包括支持库中的HorizontalScrollView和ViewPager.所以我使用ViewPager作为Gallery类的替代品.
我的目标是最终实现带有文本描述的无限滚动图像ViewPager.我使用下面的代码来实现图像ViewPager,其中包含描述每个图像的文本但是如何将无限滚动应用于ViewPager?
我之前没有使用过ViewPager,请尽量提供详细的代码.
activity_main.xml中:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/myimagepager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
custom_pager.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal">
<ImageView
android:id="@+id/myimage"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="2" />
<TextView
android:id="@+id/image_text"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
ImagePager:
public class ImagePager extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImagePagerAdapter adapter = new ImagePagerAdapter(this, imageArra, stringArray );
ViewPager myPager = (ViewPager) findViewById(R.id.myimagepager);
myPager.setAdapter(adapter);
myPager.setCurrentItem(0);
}
private int imageArra[] = { R.drawable.a, R.drawable.b,R.drawable.c,
R.drawable.d,R.drawable.e,R.drawable.f,
R.drawable.g, …
Run Code Online (Sandbox Code Playgroud) I have app start with Splash screen then open listactivity rows, clicking on any row will opens an activity containing a textview, two buttons (one of which opens an infinite gallery, the other opens a custom dialog), and menu items (about, preference, exit).
This app runs perfectly on ginger bread but when tested on a galaxy s3 running jelly bean, it opens normally but when you click on one of the listactivity rows it appears to ignore the click. The …
我自定义了选项菜单,删除了默认背景并通过参考样式自定义了它自己的项目,但是我在图片中所示的项目之间的行中删除.
任何建议将被认真考虑.
我的代码:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="1dp" android:height="1dp" android:color="#B22222" />
<solid android:color="#FCE6C9" />
<padding android:left="2dp" android:top="2dp" android:right="2dp"
android:bottom="2dp" />
<corners android:bottomRightRadius="30dp" android:bottomLeftRadius="30dp"
android:topLeftRadius="30dp" android:topRightRadius="30dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
选项菜单代码:
public class OptionMenu extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);}
public boolean onCreateOptionsMenu(android.view.Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.cool_menu, menu);
getLayoutInflater().setFactory(new Factory() {
public View onCreateView(String name, Context context,
AttributeSet attrs) {
if (name .equalsIgnoreCase("com.android.internal.view.menu.IconMenuItemView")) {
try {
LayoutInflater …
Run Code Online (Sandbox Code Playgroud) 我的一个项目活动包括用string.xml编写的长文本,我在textview中添加一些来自资源的图像,因为每个短语后都有图像,然后是文本短语然后是图像,依此类推,
我使用以下代码从字符串中获取图像:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView htmlTextView = (TextView) findViewById(R.id.day_tv);
htmlTextView.setText(Html.fromHtml(getString(R.string.day), new ImageGetter(), null));
}
private class ImageGetter implements Html.ImageGetter {
public Drawable getDrawable(String source) {
int id = 0;
if (source.equals("image1.jpg")) {
id = R.drawable.a;
} else if (source.equals("image2.jpg")) {
id = R.drawable.b;
} else if (source.equals("image3.jpg")) {
id = R.drawable.c;
} else if (source.equals("image4.jpg")) {
id = R.drawable.d;
} else if (source.equals("image5.jpg")) {
id = R.drawable.e;
} …
Run Code Online (Sandbox Code Playgroud) 基于这个例子,我有无限的画廊:
http://blog.blundell-apps.com/infinite-scrolling-gallery/ ,
它运行得很好,现在我想让图库仍然滚动图像,每个图像下面应该有一个文本标题.
我搜索网没有结果,请你帮我编码,只是初学者在开发中.
================================================== ================================
新更新:
上传照片解释我需要的东西我用普通画廊得到它(应用文本到每个图像,并能够自定义文本,如下图所示,每个图像都有diffrenet文本比其他图像,但仍然没有成功用无限画廊做到这一点:
请任何帮助和建议.
非常感谢.
我的一个应用程序活动称为DayGallery活动(无限图像库),
当我打开图库时,它会随机显示第一张图片,而不是从我在DayGallery活动代码中指定的第一张图片开始.
我想要实现的目标是:
首先:从DayGallery活动代码中指定的第一个图像开始,如下所示:
当打开Day1画廊时,首先出现的图像是:
R.drawable.day_one_1
Run Code Online (Sandbox Code Playgroud)
当打开Day2画廊时,首先出现的图像是:
R.drawable.day_two_1
Run Code Online (Sandbox Code Playgroud)
就像所有Days画廊一样,同时保持两侧的无限滚动.
第二:如果我在图库中停止了名为day_one_7的图片,然后按回去前一个活动并再次返回图库,我想看到我在离开图库之前看到的相同图像,但如果我退出应用程序然后打开再次,它必须重置,以显示我在DayGallery活动代码中指定的第一个图像,解释为贝娄图像.
实际上我搜索谷歌的目的,但我不能得到任何有用的东西,
任何帮助将受到高度赞赏.
DayGallery.java:
@SuppressWarnings("deprecation")
public class DayGallery extends Activity {
TextView tv;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
// Set the layout to use
setContentView(R.layout.main);
if (customTitleSupported) {
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title);
tv = (TextView) findViewById(R.id.title_tv1);
tv.setTypeface(FontFactory.getBFantezy(getBaseContext()));
}
InfiniteGallery galleryOne = (InfiniteGallery) findViewById(R.id.galleryOne);
galleryOne.setAdapter(initializeImages());
galleryOne.setSelection(galleryOne.getCount()/2);
}
private …
Run Code Online (Sandbox Code Playgroud) 我使用viewpager类来显示图像集而不是图库集,因为它已弃用并自定义它以使用下面的代码显示文本,问题是所有图像显示的文本相同,我试图得到的是: 不同的文本解释它的每个图像,假设我们有5个图像,它必须有5个不同的文本,每个图像描述它的图像.
任何建议将不胜感激,谢谢
代码:
ImagePager
public class ImagePager extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImagePagerAdapter adapter = new ImagePagerAdapter(this, imageArra);
ViewPager myPager = (ViewPager) findViewById(R.id.myimagepager);
myPager.setAdapter(adapter);
myPager.setCurrentItem(0);}
private int imageArra[] = { R.drawable.a, R.drawable.b, R.drawable.c,
R.drawable.d, R.drawable.e}; }
Run Code Online (Sandbox Code Playgroud)
ImagePagerAdapter
public class ImagePagerAdapter extends PagerAdapter {
Activity activity;
int imageArray[];
public ImagePagerAdapter(Activity act, int[] imgArra) {
imageArray = imgArra;
activity = act;}
public int getCount() {
return imageArray.length;}
public Object instantiateItem(View collection, int …
Run Code Online (Sandbox Code Playgroud)