Have you taken a look at CardView , here is the official tutorial , it will create UI like
I just switched to a new computer and channel's videos are in grid view instead of list view (as it was on my old computer). Add "?sort=dd&view=0&flow=grid" to the URL no longer works. Any idea how to get the list view back?
Videos
Have you taken a look at CardView , here is the official tutorial , it will create UI like
By adding style to your layouts you can round them
Define this in drawable :
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<stroke android:width="3dip" android:color="#B1BCBE" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
and add above style to the backround of your layout
android:background="@drawable/your_above_syle"
Another way is adding 9 patch images to the background of your layouts for example using this image which can round and add shadow to your layouts
of documentation,
Note that while videos are playing, this View has a minimum size of 200x110 dp. If you make the view any smaller, videos will automatically stop playing. Also, it is not permitted to overlay this fragment's view with other views while a video is playing.
xml code: list_item
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parent_relativeLayout"
android:layout_width="match_parent"
android:layout_height="270dp">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:clickable="true"
card_view:cardBackgroundColor="@android:color/black"
card_view:cardCornerRadius="5dp"
card_view:cardElevation="0dp"
card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true">
<com.google.android.youtube.player.YouTubeThumbnailView
android:id="@+id/youtube_thumbnail"
android:layout_width="match_parent"
android:layout_height="250dp"
android:scaleType="centerCrop"
android:visibility="visible" />
<RelativeLayout
android:id="@+id/relativeLayout_over_youtube_thumbnail"
android:layout_width="match_parent"
android:layout_height="250dp"
android:visibility="visible">
<ImageView
android:id="@+id/btnYoutube_player"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="center"
android:src="@android:drawable/btn_plus" />
<TextView
android:id="@+id/videosTitle_tv"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="Vidoes title here"
android:gravity="center"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
RecyclerAdapter
package com.mobileappdev.videosapp.adapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubeStandalonePlayer;
import com.google.android.youtube.player.YouTubeThumbnailLoader;
import com.google.android.youtube.player.YouTubeThumbnailView;
import com.mobileappdev.videosapp.R;
/**
* Created by ofaroque on 8/13/15.
*/
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.VideoInfoHolder> {
//these ids are the unique id for each video
String[] VideoID = {"P3mAtvs5Elc", "nCgQDjiotG0", "P3mAtvs5Elc"};
String[] Ttitles = {"Video # 1", "Video # 2", "Video # 3"};
Context ctx;
private static String KEY = "Add your authentication key for google";
public RecyclerAdapter(Context context) {
this.ctx = context;
}
@Override
public VideoInfoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
return new VideoInfoHolder(itemView);
}
@Override
public void onBindViewHolder(final VideoInfoHolder holder, final int position) {
final YouTubeThumbnailLoader.OnThumbnailLoadedListener onThumbnailLoadedListener = new YouTubeThumbnailLoader.OnThumbnailLoadedListener() {
@Override
public void onThumbnailError(YouTubeThumbnailView youTubeThumbnailView, YouTubeThumbnailLoader.ErrorReason errorReason) {
}
@Override
public void onThumbnailLoaded(YouTubeThumbnailView youTubeThumbnailView, String s) {
youTubeThumbnailView.setVisibility(View.VISIBLE);
holder.relativeLayoutOverYouTubeThumbnailView.setVisibility(View.VISIBLE);
}
};
holder.youTubeThumbnailView.initialize(KEY, new YouTubeThumbnailView.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubeThumbnailView youTubeThumbnailView, YouTubeThumbnailLoader youTubeThumbnailLoader) {
youTubeThumbnailLoader.setVideo(VideoID[position]);
youTubeThumbnailLoader.setOnThumbnailLoadedListener(onThumbnailLoadedListener);
holder.videosTitleTextView.setText(Ttitles[position]);
}
@Override
public void onInitializationFailure(YouTubeThumbnailView youTubeThumbnailView, YouTubeInitializationResult youTubeInitializationResult) {
//write something for failure
}
});
}
@Override
public int getItemCount() {
return VideoID.length;
}
public class VideoInfoHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
protected RelativeLayout relativeLayoutOverYouTubeThumbnailView;
YouTubeThumbnailView youTubeThumbnailView;
protected ImageView playButton;
protected TextView videosTitleTextView;
public VideoInfoHolder(View itemView) {
super(itemView);
playButton = (ImageView) itemView.findViewById(R.id.btnYoutube_player);
videosTitleTextView = (TextView) itemView.findViewById(R.id.videosTitle_tv);
playButton.setOnClickListener(this);
relativeLayoutOverYouTubeThumbnailView = (RelativeLayout) itemView.findViewById(R.id.relativeLayout_over_youtube_thumbnail);
youTubeThumbnailView = (YouTubeThumbnailView) itemView.findViewById(R.id.youtube_thumbnail);
}
@Override
public void onClick(View v) {
Intent intent = YouTubeStandalonePlayer.createVideoIntent((Activity) ctx, KEY, VideoID[getLayoutPosition()]);
ctx.startActivity(intent);
}
}
}
MainActivity
package com.mobileappdev.videosapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.mobileappdev.videosapp.adapter.RecyclerAdapter;
import com.mobileappdev.videosapp.models.Videos;
public class MainActivity extends AppCompatActivity {
private static String TAG = MainActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
//to use RecycleView, you need a layout manager. default is LinearLayoutManager
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(linearLayoutManager);
RecyclerAdapter adapter = new RecyclerAdapter(this);
recyclerView.setAdapter(adapter);
}
}
I'm not always against change and i understand that sometimes the interface is up for an overhaul, but the way youtube does it seems like it becomes more and more limiting. I remember being able to just go to a page of all the comments of a youtube video which was more convenient then how they are loaded now on the bottom of the page upon scrolling down. But that's another thing they changed in the past that i wasn't too happy about. What they removed now is the ability to view all the videos of a channel in list view. I'm not used to using the grid view which is very busy in my opinion and i see absolutely no reason why list view got removed. btw i'm using chrome on linux
They did it again. Just add "?sort=dd&view=0&flow=list" after "videos"
I was testing out a new browser and wondering why it showed videos list in grid mode, while my previous browser had it in list mode (the way I like). You can change it to list mode by editing cookie PREF, and adding &cvdm=list to it.