briangriffey / book-animation

book-animation
Apache License 2.0
82 stars 28 forks source link

Not working #2

Closed Toss00 closed 10 years ago

Toss00 commented 10 years ago

Hello,

I want use book animation for my application but PageTurnLayout not working.

my code :

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

    layout =  new  PageTurnLayout ( this.getBaseContext() ); 
    PageTurnLayout.LayoutParams layoutparams = new  PageTurnLayout . LayoutParams ( ViewGroup . LayoutParams.MATCH_PARENT , ViewGroup . LayoutParams.MATCH_PARENT);             
    layout . setLayoutParams ( layoutparams );
    layout.setBackgroundColor(getResources().getColor(R.color.fond));

    menus = Restaurants.menus;

    for (int i = 0; i < menus.size(); i++) {

        LinearLayout menu = new LinearLayout(layout.getContext());
        LinearLayout.LayoutParams params = new  LinearLayout . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . MATCH_PARENT , Gravity . CENTER_HORIZONTAL | Gravity . CENTER_VERTICAL );             
        menu.setLayoutParams(params);
        menu.setBackgroundColor(getResources().getColor(R.color.fond));
        menu.setOrientation ( LinearLayout . VERTICAL ); 

        TextView nom = new TextView(menu.getContext());
        nom. setLayoutParams ( new  LinearLayout . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . MATCH_PARENT, 1f ));
        nom.setGravity(Gravity . CENTER_HORIZONTAL | Gravity . CENTER_VERTICAL);
        nom.setTypeface(TBLActivity.CLB);
        nom.setTextColor(getResources().getColor(R.color.text));
        nom.setTextSize(12);
        nom.setText(menus.get(i).nom);

        TextView descriptif = new TextView(menu.getContext());
        descriptif. setLayoutParams ( new  LinearLayout . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . MATCH_PARENT, 0.4f ));
        descriptif.setGravity(Gravity . CENTER_HORIZONTAL | Gravity . CENTER_VERTICAL);
        descriptif.setTypeface(TBLActivity.CLB);
        descriptif.setTextColor(getResources().getColor(R.color.text));
        descriptif.setTextSize(6);
        descriptif.setText(menus.get(i).descriptif);

        TextView prix = new TextView(menu.getContext());
        prix. setLayoutParams ( new  LinearLayout . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . MATCH_PARENT, 1f ));
        prix.setGravity(Gravity . CENTER_HORIZONTAL | Gravity . CENTER_VERTICAL);
        prix.setTypeface(TBLActivity.CLB);
        prix.setTextColor(getResources().getColor(R.color.text));
        prix.setTextSize(5);
        prix.setText(menus.get(i).prix);

        menu.addView(nom);
        menu.addView(descriptif);
        menu.addView(prix);

        layout.addView(menu);

    }

    setContentView(layout);
}